function TextWidget::formElement
Same name in this branch
- 8.x-1.x field_permission_example/src/Plugin/Field/FieldWidget/TextWidget.php \Drupal\field_permission_example\Plugin\Field\FieldWidget\TextWidget::formElement()
Same name in other branches
- 3.x modules/field_permission_example/src/Plugin/Field/FieldWidget/TextWidget.php \Drupal\field_permission_example\Plugin\Field\FieldWidget\TextWidget::formElement()
- 3.x modules/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()
1 call to TextWidget::formElement()
- ColorPickerWidget::formElement in field_example/
src/ Plugin/ Field/ FieldWidget/ ColorPickerWidget.php
1 method overrides TextWidget::formElement()
- ColorPickerWidget::formElement in field_example/
src/ Plugin/ Field/ FieldWidget/ ColorPickerWidget.php
File
-
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 = isset($items[$delta]->value) ? $items[$delta]->value : '';
$element += [
'#type' => 'textfield',
'#default_value' => $value,
'#size' => 7,
'#maxlength' => 7,
'#element_validate' => [
[
$this,
'validate',
],
],
];
return [
'value' => $element,
];
}