FormErrorHandler::displayErrorMessages

protected FormErrorHandler::displayErrorMessages(array $form, FormStateInterface $form_state)

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.

File

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

Class

FormErrorHandler
Handles form errors.

Namespace

Drupal\Core\Form

Code

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->drupalSetMessage($error, 'error');
  }
}
doc_Drupal
2016-10-29 09:15:40
Comments
Leave a Comment

Please login to continue.