function FormErrorHandler::handleFormErrors

Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Form/FormErrorHandler.php \Drupal\Core\Form\FormErrorHandler::handleFormErrors()
  2. 10 core/lib/Drupal/Core/Form/FormErrorHandler.php \Drupal\Core\Form\FormErrorHandler::handleFormErrors()
  3. 11.x core/lib/Drupal/Core/Form/FormErrorHandler.php \Drupal\Core\Form\FormErrorHandler::handleFormErrors()

Overrides FormErrorHandlerInterface::handleFormErrors

File

core/lib/Drupal/Core/Form/FormErrorHandler.php, line 19

Class

FormErrorHandler
Handles form errors.

Namespace

Drupal\Core\Form

Code

public function handleFormErrors(array &$form, FormStateInterface $form_state) {
    // After validation check if there are errors.
    if ($form_state->getErrors()) {
        // Display error messages for each element.
        $this->displayErrorMessages($form, $form_state);
        // Loop through and assign each element its errors.
        $this->setElementErrorsFromFormState($form, $form_state);
    }
    return $this;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.