function ShapeOnlyColorEditableWidget::formElement
Same name in other branches
- 9 core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldWidget/ShapeOnlyColorEditableWidget.php \Drupal\entity_test\Plugin\Field\FieldWidget\ShapeOnlyColorEditableWidget::formElement()
- 8.9.x core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldWidget/ShapeOnlyColorEditableWidget.php \Drupal\entity_test\Plugin\Field\FieldWidget\ShapeOnlyColorEditableWidget::formElement()
- 10 core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldWidget/ShapeOnlyColorEditableWidget.php \Drupal\entity_test\Plugin\Field\FieldWidget\ShapeOnlyColorEditableWidget::formElement()
Overrides WidgetInterface::formElement
File
-
core/
modules/ system/ tests/ modules/ entity_test/ src/ Plugin/ Field/ FieldWidget/ ShapeOnlyColorEditableWidget.php, line 26
Class
- ShapeOnlyColorEditableWidget
- Plugin implementation of the 'shape_only_color_editable_widget' widget.
Namespace
Drupal\entity_test\Plugin\Field\FieldWidgetCode
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$element['shape'] = [
'#type' => 'hidden',
'#value' => $items[$delta]->shape,
];
$element['color'] = [
'#type' => 'textfield',
'#default_value' => $items[$delta]->color ?? NULL,
'#size' => 255,
];
return $element;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.