FormErrorHandler
class FormErrorHandler implements FormErrorHandlerInterface (View source)
Handles form errors.
Traits
Provides a trait for the messenger service.
Properties
| protected MessengerInterface | $messenger | The messenger. |
from MessengerTrait |
Methods
Handles form errors after form validation.
Loops through and displays all form errors.
Stores errors and a list of child element errors directly on each element.
Details
setMessenger(MessengerInterface $messenger)
Sets the messenger.
MessengerInterface
messenger()
Gets the messenger.
$this
handleFormErrors(array $form, FormStateInterface $form_state)
Handles form errors after form validation.
protected
displayErrorMessages(array $form, FormStateInterface $form_state)
Loops through and displays all form errors.
protected
setElementErrorsFromFormState(array $form, FormStateInterface $form_state, array $elements = [])
Stores errors and a list of child element errors directly on each element.
Grouping elements like containers, details, fieldgroups and fieldsets may need error info from their child elements to be able to accessibly show form error messages to a user. For example, a details element should be opened when child elements have errors.
Grouping example: Assume you have a 'street' element somewhere in a form, which is displayed in a details element 'address'. It might be: