You are here

public function FormWidgetInterface::form in Typed Data API enhancements 8

Creates the widget's form elements for editing the given data.

Note that the FAPI element callbacks (such as #process, #element_validate, #value_callback, etc.) used by the widget do not have access to the definition passed to this method. Therefore, if any information is needed from that definition by those callbacks, the widget implementing this method must extract the needed properties from the data definition and set them as ad-hoc $element['#custom'] properties, for later use by its element callbacks.

Parameters

\Drupal\Core\TypedData\TypedDataInterface $data: The data to be edited.

\Drupal\Core\Form\SubformStateInterface $form_state: The form state of the widget's form.

Return value

array[] The form elements for the given data. Note that this must be an array, holding one or more form-elements.

6 methods override FormWidgetInterface::form()
BrokenWidget::form in src/Plugin/TypedDataFormWidget/BrokenWidget.php
Creates the widget's form elements for editing the given data.
DatetimeRangeWidget::form in src/Plugin/TypedDataFormWidget/DatetimeRangeWidget.php
Creates the widget's form elements for editing the given data.
DatetimeWidget::form in src/Plugin/TypedDataFormWidget/DatetimeWidget.php
Creates the widget's form elements for editing the given data.
SelectWidget::form in src/Plugin/TypedDataFormWidget/SelectWidget.php
Creates the widget's form elements for editing the given data.
TextareaWidget::form in src/Plugin/TypedDataFormWidget/TextareaWidget.php
Creates the widget's form elements for editing the given data.

... See full list

File

src/Widget/FormWidgetInterface.php, line 48

Class

FormWidgetInterface
Interface definition for form widget plugins.

Namespace

Drupal\typed_data\Widget

Code

public function form(TypedDataInterface $data, SubformStateInterface $form_state);