public function FormErrorHandler::handleFormErrors in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Form/FormErrorHandler.php \Drupal\Core\Form\FormErrorHandler::handleFormErrors()
Handles form errors after form validation.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
$this
Overrides FormErrorHandlerInterface::handleFormErrors
File
- core/
lib/ Drupal/ Core/ Form/ FormErrorHandler.php, line 19
Class
- FormErrorHandler
- Handles form errors.
Namespace
Drupal\Core\FormCode
public function handleFormErrors(array &$form, FormStateInterface $form_state) {
// After validation check if there are errors.
if ($errors = $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;
}