public function WebformSubmissionForm::noValidate in Webform 8.5
Same name and namespace in other branches
- 6.x src/WebformSubmissionForm.php \Drupal\webform\WebformSubmissionForm::noValidate()
Webform submission validation that does nothing but clear validation errors.
This method is used by wizard/preview previous buttons and the reset button to prevent all form validation errors from being displayed while still allowing an element's #validate callback to be triggered.
This callback is being used instead of adding #limit_validation_errors = [] to the submit buttons because #limit_validation_errors also ignores all form values set via an element's #validate callback.
More complex (web)form elements user #validate callbacks to process and alter an element's submitted value. Element's that rely on #validate to alter the submitted value include 'Password Confirm', 'Email Confirm', 'Composite Elements', 'Other Elements', and more…
If the #limit_validation_errors property is used within a multi-step wizard form, previously submitted values will be corrupted.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides WebformDialogFormTrait::noValidate
See also
\Drupal\Core\Form\FormValidator::handleErrorsWithLimitedValidation
\Drupal\Core\Render\Element\PasswordConfirm::validatePasswordConfirm
\Drupal\webform\Element\WebformEmailConfirm
\Drupal\webform\Element\WebformOtherBase::validateWebformOther
File
- src/
WebformSubmissionForm.php, line 1829
Class
- WebformSubmissionForm
- Provides a webform to collect and edit submissions.
Namespace
Drupal\webformCode
public function noValidate(array &$form, FormStateInterface $form_state) {
$form_state
->clearErrors();
$this->entity
->validate();
}