public function ExampleFieldEventSubscribers::alterWidgetForm in Hook Event Dispatcher 3.x
Same name and namespace in other branches
- 8.2 examples/ExampleFieldEventSubscribers.php \Drupal\hook_event_dispatcher\ExampleFieldEventSubscribers::alterWidgetForm()
Alter widget form.
Parameters
\Drupal\field_event_dispatcher\Event\Field\WidgetFormAlterEvent $event: The event.
File
- examples/
ExampleFieldEventSubscribers.php, line 29
Class
- ExampleFieldEventSubscribers
- Class ExampleFieldEventSubscribers.
Namespace
Drupal\hook_event_dispatcherCode
public function alterWidgetForm(WidgetFormAlterEvent $event) : void {
$element =& $event
->getElement();
$element['extra_field'] = [
'#type' => 'textfield',
'#title' => 'I am an extra field!',
];
}