public function ExampleFieldEventSubscribers::alterWidgetStringTextField in Hook Event Dispatcher 8.2
Same name and namespace in other branches
- 3.x examples/ExampleFieldEventSubscribers.php \Drupal\hook_event_dispatcher\ExampleFieldEventSubscribers::alterWidgetStringTextField()
Alter widget string text field.
Parameters
\Drupal\field_event_dispatcher\Event\Field\WidgetTypeFormAlterEvent $event: The event.
File
- examples/
ExampleFieldEventSubscribers.php, line 43
Class
- ExampleFieldEventSubscribers
- Class ExampleFieldEventSubscribers.
Namespace
Drupal\hook_event_dispatcherCode
public function alterWidgetStringTextField(WidgetTypeFormAlterEvent $event) : void {
$element =& $event
->getElement();
// Do something cool.
$element['special_label'] = [
'type' => 'label',
'label' => 'Extra special label',
];
}