hook_field_widget_WIDGET_TYPE_form_alter(&$element, \Drupal\Core\Form\FormStateInterface $form_state, $context)
Alter widget forms for a specific widget provided by another module.
Modules can implement hook_field_widget_WIDGET_TYPE_form_alter() to modify a specific widget form, rather than using hook_field_widget_form_alter() and checking the widget type.
$element: The field widget form element as constructed by hook_field_widget_form().
$form_state: The current state of the form.
$context: An associative array. See hook_field_widget_form_alter() for the structure and content of the array.
\Drupal\Core\Field\WidgetBase::formSingleElement()
hook_field_widget_form_alter()
function hook_field_widget_WIDGET_TYPE_form_alter(&$element, \Drupal\Core\Form\FormStateInterface $form_state, $context) { // Code here will only act on widgets of type WIDGET_TYPE. For example, // hook_field_widget_mymodule_autocomplete_form_alter() will only act on // widgets of type 'mymodule_autocomplete'. $element['#autocomplete_route_name'] = 'mymodule.autocomplete_route'; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!field!field.api.php/function/hook_field_widget_WIDGET_TYPE_form_alter/8.1.x