diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php index 1046499..974d309 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -857,7 +857,7 @@ public function validateForm($form_id, &$form, &$form_state) { // Recursively validate each form element. $this->doValidateForm($form, $form_state, $form_id); // After validation, loop through and assign each element its errors. - $this->doCheckErrors($form, $form_state); + $this->setElementErrorsFromFormState($form, $form_state); // Mark this form as validated. $this->validatedForms[$form_id] = TRUE; @@ -1157,11 +1157,11 @@ protected function doValidateForm(&$elements, &$form_state, $form_id = NULL) { * @param array $form_state * An associative array containing the current state of the form. */ - protected function doCheckErrors(array &$elements, array &$form_state) { + protected function setElementErrorsFromFormState(array &$elements, array &$form_state) { // Recurse through all children. foreach ($this->elementChildren($elements) as $key) { if (isset($elements[$key]) && $elements[$key]) { - $this->doCheckErrors($elements[$key], $form_state); + $this->setElementErrorsFromFormState($elements[$key], $form_state); } } // Store the errors for this element on the element directly. diff --git a/core/lib/Drupal/Core/Form/FormBuilderInterface.php b/core/lib/Drupal/Core/Form/FormBuilderInterface.php index 6e580c7..2144065 100644 --- a/core/lib/Drupal/Core/Form/FormBuilderInterface.php +++ b/core/lib/Drupal/Core/Form/FormBuilderInterface.php @@ -513,14 +513,14 @@ public function executeHandlers($type, &$form, &$form_state); * * When a validation error is detected, the validator calls form_set_error() * to indicate which element needs to be changed and provide an error message. - * This causes the Form API to not execute the form submit handlers, $form_state, and + * This causes the Form API to not execute the form submit handlers, and * instead to re-display the form to the user with the corresponding elements * rendered with an 'error' CSS class (shown as red by default). * * The standard form_set_error() behavior can be changed if a button provides * the #limit_validation_errors property. Multistep forms not wanting to * validate the whole form can set #limit_validation_errors on buttons to - * limit validation errors to only certain elements. For example, $form_state, pressing the + * limit validation errors to only certain elements. For example, pressing the * "Previous" button in a multistep form should not fire validation errors * just because the current step has invalid values. If * #limit_validation_errors is set on a clicked button, the button must also @@ -567,12 +567,13 @@ public function executeHandlers($type, &$form, &$form_state); * This will require $form_state['values']['step1'] and everything within it * (for example, $form_state['values']['step1']['choice']) to be valid, so * calls to form_set_error('step1', $form_state, $message) or - * form_set_error('step1][choice', $form_state, $message) will prevent the submit handlers - * from running, and result in the error message being displayed to the user. - * However, calls to form_set_error('step2', $form_state, $message) and - * form_set_error('step2][groupX][choiceY', $form_state, $message) will be suppressed, - * resulting in the message not being displayed to the user, and the submit - * handlers will run despite $form_state['values']['step2'] and + * form_set_error('step1][choice', $form_state, $message) will prevent the + * submit handlers from running, and result in the error message being + * displayed to the user. However, calls to + * form_set_error('step2', $form_state, $message) and + * form_set_error('step2][groupX][choiceY', $form_state, $message) will be + * suppressed, resulting in the message not being displayed to the user, and + * the submitdoCheckErrors handlers will run despite $form_state['values']['step2'] and * $form_state['values']['step2']['groupX']['choiceY'] containing invalid * values. Errors for an invalid $form_state['values']['foo'] will be * suppressed, but errors flagging invalid values for