function TextWidget::formElement
Same name in this branch
- 3.x modules/field_permission_example/src/Plugin/Field/FieldWidget/TextWidget.php \Drupal\field_permission_example\Plugin\Field\FieldWidget\TextWidget::formElement()
Same name in other branches
- 8.x-1.x field_permission_example/src/Plugin/Field/FieldWidget/TextWidget.php \Drupal\field_permission_example\Plugin\Field\FieldWidget\TextWidget::formElement()
- 8.x-1.x field_example/src/Plugin/Field/FieldWidget/TextWidget.php \Drupal\field_example\Plugin\Field\FieldWidget\TextWidget::formElement()
- 4.0.x modules/field_permission_example/src/Plugin/Field/FieldWidget/TextWidget.php \Drupal\field_permission_example\Plugin\Field\FieldWidget\TextWidget::formElement()
- 4.0.x modules/field_example/src/Plugin/Field/FieldWidget/TextWidget.php \Drupal\field_example\Plugin\Field\FieldWidget\TextWidget::formElement()
Overrides WidgetInterface::formElement
1 call to TextWidget::formElement()
- ColorPickerWidget::formElement in modules/
field_example/ src/ Plugin/ Field/ FieldWidget/ ColorPickerWidget.php - Returns the form for a single field widget.
1 method overrides TextWidget::formElement()
- ColorPickerWidget::formElement in modules/
field_example/ src/ Plugin/ Field/ FieldWidget/ ColorPickerWidget.php - Returns the form for a single field widget.
File
-
modules/
field_example/ src/ Plugin/ Field/ FieldWidget/ TextWidget.php, line 27
Class
- TextWidget
- Plugin implementation of the 'field_example_text' widget.
Namespace
Drupal\field_example\Plugin\Field\FieldWidgetCode
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$value = $items[$delta]->value ?? '';
$element += [
'#type' => 'textfield',
'#default_value' => $value,
'#size' => 7,
'#maxlength' => 7,
'#element_validate' => [
[
$this,
'validate',
],
],
];
return [
'value' => $element,
];
}