public function YamlFormSubmissionForm::validateForm in YAML Form 8
Button-level validation handlers are highly discouraged for entity forms, as they will prevent entity validation from running. If the entity is going to be saved during the form submission, this method should be manually invoked from the button-level validation handler, otherwise an exception will be thrown.
Overrides ContentEntityForm::validateForm
1 call to YamlFormSubmissionForm::validateForm()
- YamlFormTemplatesSubmissionPreviewForm::validateForm in modules/
yamlform_templates/ src/ YamlFormTemplatesSubmissionPreviewForm.php - Button-level validation handlers are highly discouraged for entity forms, as they will prevent entity validation from running. If the entity is going to be saved during the form submission, this method should be manually invoked from the button-level…
1 method overrides YamlFormSubmissionForm::validateForm()
- YamlFormTemplatesSubmissionPreviewForm::validateForm in modules/
yamlform_templates/ src/ YamlFormTemplatesSubmissionPreviewForm.php - Button-level validation handlers are highly discouraged for entity forms, as they will prevent entity validation from running. If the entity is going to be saved during the form submission, this method should be manually invoked from the button-level…
File
- src/
YamlFormSubmissionForm.php, line 743
Class
- YamlFormSubmissionForm
- Provides a form to collect and edit submissions.
Namespace
Drupal\yamlformCode
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
// Validate form via form handler.
$this
->getYamlForm()
->invokeHandlers('validateForm', $form, $form_state, $this->entity);
// Form validate handlers (via form['#validate']) are not called when
// #validate handlers are attached to the trigger element
// (ie submit button), so we need to manually call $form['validate']
// handlers to support the modules that use form['#validate'] like the
// validators.module.
// @see \Drupal\yamlform\YamlFormSubmissionForm::actions
// @see \Drupal\Core\Form\FormBuilder::doBuildForm
$trigger_element = $form_state
->getTriggeringElement();
if (isset($trigger_element['#validate'])) {
$handlers = array_filter($form['#validate'], function ($callback) {
// Remove ::validateForm to prevent a recursion.
return is_array($callback) || $callback != '::validateForm';
});
// @see \Drupal\Core\Form\FormValidator::executeValidateHandlers
foreach ($handlers as $callback) {
call_user_func_array($form_state
->prepareCallback($callback), [
&$form,
&$form_state,
]);
}
}
}