function TextWidget::formElement

Same name in this branch
  1. 4.0.x modules/field_example/src/Plugin/Field/FieldWidget/TextWidget.php \Drupal\field_example\Plugin\Field\FieldWidget\TextWidget::formElement()
Same name in other branches
  1. 3.x modules/field_permission_example/src/Plugin/Field/FieldWidget/TextWidget.php \Drupal\field_permission_example\Plugin\Field\FieldWidget\TextWidget::formElement()
  2. 3.x modules/field_example/src/Plugin/Field/FieldWidget/TextWidget.php \Drupal\field_example\Plugin\Field\FieldWidget\TextWidget::formElement()

Overrides WidgetInterface::formElement

File

modules/field_permission_example/src/Plugin/Field/FieldWidget/TextWidget.php, line 26

Class

TextWidget
Plugin implementation of the 'field_permission_example_widget' widget.

Namespace

Drupal\field_permission_example\Plugin\Field\FieldWidget

Code

public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
    $value = $items[$delta]->value ?? '';
    $element += [
        '#type' => 'textarea',
        '#default_value' => $value,
    ];
    return [
        'value' => $element,
    ];
}