protected function FormValidator::determineLimitValidationErrors in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Form/FormValidator.php \Drupal\Core\Form\FormValidator::determineLimitValidationErrors()
Determines if validation errors should be limited.
Parameters
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array|null
1 call to FormValidator::determineLimitValidationErrors()
- FormValidator::doValidateForm in core/
lib/ Drupal/ Core/ Form/ FormValidator.php - Performs validation on form elements.
File
- core/
lib/ Drupal/ Core/ Form/ FormValidator.php, line 381
Class
- FormValidator
- Provides validation of form submissions.
Namespace
Drupal\Core\FormCode
protected function determineLimitValidationErrors(FormStateInterface &$form_state) {
// While this element is being validated, it may be desired that some
// calls to \Drupal\Core\Form\FormStateInterface::setErrorByName() be
// suppressed and not result in a form error, so that a button that
// implements low-risk functionality (such as "Previous" or "Add more") that
// doesn't require all user input to be valid can still have its submit
// handlers triggered. The triggering element's #limit_validation_errors
// property contains the information for which errors are needed, and all
// other errors are to be suppressed. The #limit_validation_errors property
// is ignored if submit handlers will run, but the element doesn't have a
// #submit property, because it's too large a security risk to have any
// invalid user input when executing form-level submit handlers.
$triggering_element = $form_state
->getTriggeringElement();
if (isset($triggering_element['#limit_validation_errors']) && $triggering_element['#limit_validation_errors'] !== FALSE && !($form_state
->isSubmitted() && !isset($triggering_element['#submit']))) {
return $triggering_element['#limit_validation_errors'];
}
elseif ($triggering_element && !isset($triggering_element['#limit_validation_errors']) && !$form_state
->isSubmitted()) {
return [];
}
else {
return NULL;
}
}