public static function WebformSubmissionConditionsValidator::elementValidate in Webform 8.5
Same name and namespace in other branches
- 6.x src/WebformSubmissionConditionsValidator.php \Drupal\webform\WebformSubmissionConditionsValidator::elementValidate()
Webform conditional #element_validate callback: Execute #element_validate and suppress errors.
File
- src/
WebformSubmissionConditionsValidator.php, line 470
Class
- WebformSubmissionConditionsValidator
- Webform submission conditions (#states) validator.
Namespace
Drupal\webformCode
public static function elementValidate(array &$element, FormStateInterface $form_state) {
// Element validation is trigger sequentially.
// Triggers must be validated before dependants.
//
// Build webform submission with validated and processed data.
// Webform submission must be rebuilt every time since the
// $element and $form_state values can be changed by validation callbacks.
/** @var \Drupal\webform\WebformSubmissionForm $form_object */
$form_object = $form_state
->getFormObject();
$complete_form =& $form_state
->getCompleteForm();
$webform_submission = $form_object
->buildEntity($complete_form, $form_state);
/** @var \Drupal\webform\WebformSubmissionConditionsValidatorInterface $conditions_validator */
$conditions_validator = \Drupal::service('webform_submission.conditions_validator');
if ($conditions_validator
->isElementVisible($element, $webform_submission)) {
WebformElementHelper::triggerElementValidate($element, $form_state);
}
else {
WebformElementHelper::suppressElementValidate($element, $form_state);
}
}