protected FormValidator::determineLimitValidationErrors(FormStateInterface &$form_state)
Determines if validation errors should be limited.
Parameters
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array|null
File
- core/lib/Drupal/Core/Form/FormValidator.php, line 376
Class
- FormValidator
- Provides validation of form submissions.
Namespace
Drupal\Core\Form
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 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' ]; } // If submit handlers won't run (due to the submission having been // triggered by an element whose #executes_submit_callback property isn't // TRUE), then it's safe to suppress all validation errors, and we do so // by default, which is particularly useful during an Ajax submission // triggered by a non-button. An element can override this default by // setting the #limit_validation_errors property. For button element // types, #limit_validation_errors defaults to FALSE, so that full // validation is their default behavior. elseif ( $triggering_element && !isset( $triggering_element [ '#limit_validation_errors' ]) && ! $form_state ->isSubmitted()) { return array (); } // As an extra security measure, explicitly turn off error suppression if // one of the above conditions wasn't met. Since this is also done at the // end of this function, doing it here is only to handle the rare edge // case where a validate handler invokes form processing of another form. else { return NULL; } } |
Please login to continue.