function OptionsWidgetBase::formElement
Same name in other branches
- 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php \Drupal\Core\Field\Plugin\Field\FieldWidget\OptionsWidgetBase::formElement()
- 10 core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php \Drupal\Core\Field\Plugin\Field\FieldWidget\OptionsWidgetBase::formElement()
- 11.x core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php \Drupal\Core\Field\Plugin\Field\FieldWidget\OptionsWidgetBase::formElement()
Overrides WidgetInterface::formElement
2 calls to OptionsWidgetBase::formElement()
- OptionsButtonsWidget::formElement in core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldWidget/ OptionsButtonsWidget.php - Returns the form for a single field widget.
- OptionsSelectWidget::formElement in core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldWidget/ OptionsSelectWidget.php - Returns the form for a single field widget.
2 methods override OptionsWidgetBase::formElement()
- OptionsButtonsWidget::formElement in core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldWidget/ OptionsButtonsWidget.php - Returns the form for a single field widget.
- OptionsSelectWidget::formElement in core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldWidget/ OptionsSelectWidget.php - Returns the form for a single field widget.
File
-
core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldWidget/ OptionsWidgetBase.php, line 45
Class
- OptionsWidgetBase
- Base class for the 'options_*' widgets.
Namespace
Drupal\Core\Field\Plugin\Field\FieldWidgetCode
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
// Prepare some properties for the child methods to build the actual form
// element.
$this->required = $element['#required'];
$this->multiple = $this->fieldDefinition
->getFieldStorageDefinition()
->isMultiple();
$this->has_value = isset($items[0]->{$this->column});
// Add our custom validator.
$element['#element_validate'][] = [
get_class($this),
'validateElement',
];
$element['#key_column'] = $this->column;
// The rest of the $element is built by child method implementations.
return $element;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.