function WidgetInterface::errorElement

Same name in other branches
  1. 9 core/lib/Drupal/Core/Field/WidgetInterface.php \Drupal\Core\Field\WidgetInterface::errorElement()
  2. 10 core/lib/Drupal/Core/Field/WidgetInterface.php \Drupal\Core\Field\WidgetInterface::errorElement()
  3. 11.x core/lib/Drupal/Core/Field/WidgetInterface.php \Drupal\Core\Field\WidgetInterface::errorElement()

Assigns a field-level validation error to the right widget sub-element.

Depending on the widget's internal structure, a field-level validation error needs to be flagged on the right sub-element.

Parameters

array $element: An array containing the form element for the widget, as generated by formElement().

\Symfony\Component\Validator\ConstraintViolationInterface $violation: A constraint violation reported during the validation phase.

array $form: The form structure where field elements are attached to. This might be a full form structure, or a sub-element of a larger form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array|bool The element on which the error should be flagged, or FALSE to completely ignore the violation (use with care!).

1 method overrides WidgetInterface::errorElement()
WidgetBase::errorElement in core/lib/Drupal/Core/Field/WidgetBase.php
Assigns a field-level validation error to the right widget sub-element.

File

core/lib/Drupal/Core/Field/WidgetInterface.php, line 127

Class

WidgetInterface
Interface definition for field widget plugins.

Namespace

Drupal\Core\Field

Code

public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state);

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