WidgetBaseInterface

Base interface definition for "Field widget" plugins. This interface details base wrapping methods that most widget implementations will want to directly inherit from Drupal\Core\Field\WidgetBase. See Drupal\Core\Field\WidgetInterface for methods that will more likely be overridden in actual widget implementations. Hierarchy interface \Drupal\Component\Plugin\PluginInspectionInterface; interface \Drupal\Core\Config\Entity\ThirdPartySettingsInterfaceinterface \Drupal\Core\Field\PluginSettingsInt

WidgetBaseInterface::extractFormValues

public WidgetBaseInterface::extractFormValues(FieldItemListInterface $items, array $form, FormStateInterface $form_state) Extracts field values from submitted form values. Parameters \Drupal\Core\Field\FieldItemListInterface $items: The field values. This parameter is altered by reference to receive the incoming form values. 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\FormStateIn

WidgetBaseInterface::flagErrors

public WidgetBaseInterface::flagErrors(FieldItemListInterface $items, ConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state) Reports field-level validation errors against actual form elements. Parameters \Drupal\Core\Field\FieldItemListInterface $items: The field values. \Symfony\Component\Validator\ConstraintViolationListInterface $violations: A list of constraint violations to flag. array $form: The form structure where field elements are attached to. This

WidgetBaseInterface::form

public WidgetBaseInterface::form(FieldItemListInterface $items, array &$form, FormStateInterface $form_state, $get_delta = NULL) Creates a form element for a field. If the entity associated with the form is new (i.e., $entity->isNew() is TRUE), the 'default value', if any, is pre-populated. Also allows other modules to alter the form element by implementing their own hooks. Parameters \Drupal\Core\Field\FieldItemListInterface $items: An array of the field values. When creating a new ent

WidgetBaseInterface::getWidgetState

public static WidgetBaseInterface::getWidgetState(array $parents, $field_name, FormStateInterface $form_state) Retrieves processing information about the widget from $form_state. This method is static so that it can be used in static Form API callbacks. Parameters array $parents: The array of #parents where the field lives in the form. string $field_name: The field name. \Drupal\Core\Form\FormStateInterface $form_state: The form state. Return value array An array with the following key/value

WidgetBaseInterface::setWidgetState

public static WidgetBaseInterface::setWidgetState(array $parents, $field_name, FormStateInterface $form_state, array $field_state) Stores processing information about the widget in $form_state. This method is static so that it can be used in static Form API #callbacks. Parameters array $parents: The array of #parents where the widget lives in the form. string $field_name: The field name. \Drupal\Core\Form\FormStateInterface $form_state: The form state. array $field_state: The array of data to

WidgetInterface

Interface definition for field widget plugins. This interface details the methods that most plugin implementations will want to override. See Drupal\Core\Field\WidgetBaseInterface for base wrapping methods that should most likely be inherited directly from Drupal\Core\Field\WidgetBase.. Hierarchy interface \Drupal\Component\Plugin\PluginInspectionInterface; interface \Drupal\Core\Config\Entity\ThirdPartySettingsInterfaceinterface \Drupal\Core\Field\PluginSettingsInterfaceinterface \Drupal\Core\

WidgetInterface::errorElement

public WidgetInterface::errorElement(array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state) 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\ConstraintViolationInter

WidgetInterface::formElement

public WidgetInterface::formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) Returns the form for a single field widget. Field widget form elements should be based on the passed-in $element, which contains the base form element properties derived from the field configuration. The BaseWidget methods will set the weight, field name and delta values for each form element. If there are multiple values for this field, the formElement()

WidgetInterface::isApplicable

public static WidgetInterface::isApplicable(FieldDefinitionInterface $field_definition) Returns if the widget can be used for the provided field. Parameters \Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition that should be checked. Return value bool TRUE if the widget can be used, FALSE otherwise. File core/lib/Drupal/Core/Field/WidgetInterface.php, line 159 Class WidgetInterface Interface definition for field widget plugins. Namespace Drupal\Core\Fiel