function FormErrorHandler::displayErrorMessages
Same name in this branch
- 10 core/modules/inline_form_errors/src/FormErrorHandler.php \Drupal\inline_form_errors\FormErrorHandler::displayErrorMessages()
Same name in other branches
- 9 core/modules/inline_form_errors/src/FormErrorHandler.php \Drupal\inline_form_errors\FormErrorHandler::displayErrorMessages()
- 9 core/lib/Drupal/Core/Form/FormErrorHandler.php \Drupal\Core\Form\FormErrorHandler::displayErrorMessages()
- 8.9.x core/modules/inline_form_errors/src/FormErrorHandler.php \Drupal\inline_form_errors\FormErrorHandler::displayErrorMessages()
- 8.9.x core/lib/Drupal/Core/Form/FormErrorHandler.php \Drupal\Core\Form\FormErrorHandler::displayErrorMessages()
- 11.x core/modules/inline_form_errors/src/FormErrorHandler.php \Drupal\inline_form_errors\FormErrorHandler::displayErrorMessages()
- 11.x core/lib/Drupal/Core/Form/FormErrorHandler.php \Drupal\Core\Form\FormErrorHandler::displayErrorMessages()
Loops through and displays all form errors.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
2 calls to FormErrorHandler::displayErrorMessages()
- FormErrorHandler::displayErrorMessages in core/
modules/ inline_form_errors/ src/ FormErrorHandler.php - Loops through and displays all form errors.
- FormErrorHandler::handleFormErrors in core/
lib/ Drupal/ Core/ Form/ FormErrorHandler.php
1 method overrides FormErrorHandler::displayErrorMessages()
- FormErrorHandler::displayErrorMessages in core/
modules/ inline_form_errors/ src/ FormErrorHandler.php - Loops through and displays all form errors.
File
-
core/
lib/ Drupal/ Core/ Form/ FormErrorHandler.php, line 40
Class
- FormErrorHandler
- Handles form errors.
Namespace
Drupal\Core\FormCode
protected function displayErrorMessages(array $form, FormStateInterface $form_state) {
$errors = $form_state->getErrors();
// Loop through all form errors and set an error message.
foreach ($errors as $error) {
$this->messenger()
->addMessage($error, 'error');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.