function hook_field_widget_WIDGET_TYPE_form_alter in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/field/field.api.php \hook_field_widget_WIDGET_TYPE_form_alter()
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.
Parameters
$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.
See also
\Drupal\Core\Field\WidgetBase::formSingleElement()
hook_field_widget_form_alter()
Related topics
File
- core/
modules/ field/ field.api.php, line 180
Code
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';
}