public function 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().

array $error: An associative array with the following key-value pairs, as returned by hook_field_validate():

  • error: the error code. Complex widgets might need to report different errors to different form elements inside the widget.
  • message: the human readable message to be displayed.

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.

array $form_state: An associative array containing the current state of the form.

Return value

array The element on which the error should be flagged.

1 method overrides WidgetInterface::errorElement()
WidgetBase::errorElement in drupal/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetBase.php
Implements Drupal\field\Plugin\Type\Widget\WidgetInterface::errorElement().

File

drupal/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetInterface.php, line 141
Definition of Drupal\field\Plugin\Type\Widget\WidgetInterface.

Class

WidgetInterface
Interface definition for field widget plugins.

Namespace

Drupal\field\Plugin\Type\Widget

Code

public function errorElement(array $element, array $error, array $form, array &$form_state);