diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php index a2873ed..5bbb33f 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -825,17 +825,14 @@ public function validateForm($form_id, &$form, &$form_state) { // Stop here and don't run any further validation handlers, because they // could invoke non-safe operations which opens the door for CSRF // vulnerabilities. - $this->validatedForms[$form_id] = TRUE; + $this->finalizeValidation($form_id, $form, $form_state); return; } } // Recursively validate each form element. $this->doValidateForm($form, $form_state, $form_id); - // After validation, loop through and assign each element its errors. - $this->setElementErrorsFromFormState($form, $form_state); - // Mark this form as validated. - $this->validatedForms[$form_id] = TRUE; + $this->finalizeValidation($form_id, $form, $form_state); // If validation errors are limited then remove any non validated form values, // so that only values that passed validation are left for submit callbacks. @@ -876,6 +873,23 @@ public function validateForm($form_id, &$form, &$form_state) { } $form_state['values'] = $values; } + } + + /** + * Finalizes validation. + * + * @param string $form_id + * The unique string identifying the form. + * @param array $form + * An associative array containing the structure of the form. + * @param array $form_state + * An associative array containing the current state of the form. + */ + protected function finalizeValidation($form_id, &$form, &$form_state) { + // After validation, loop through and assign each element its errors. + $this->setElementErrorsFromFormState($form, $form_state); + // Mark this form as validated. + $this->validatedForms[$form_id] = TRUE; if (!$form_state['programmed']) { $form['#errors'] = $this->getErrors($form_state); } diff --git a/core/lib/Drupal/Core/Render/Element.php b/core/lib/Drupal/Core/Render/Element.php index 462efa9..3dcb446 100644 --- a/core/lib/Drupal/Core/Render/Element.php +++ b/core/lib/Drupal/Core/Render/Element.php @@ -147,7 +147,7 @@ public static function getVisibleChildren(array $elements) { * TRUE if the element is visible, otherwise FALSE. */ public static function isVisibleElement($element) { - return !isset($element['#type']) || !in_array($element['#type'], array('value', 'hidden')); + return !isset($element['#type']) || !in_array($element['#type'], array('value', 'hidden', 'token')); } /**