2 * Implements hook_field_widget_form_alter().
4 function {{ machine_name }}_field_widget_form_alter(&$element, &$form_state, $context) {
5 // Add a css class to widget form elements for all fields of type mytype.
6 if ($context['field']['type'] == 'mytype') {
7 // Be sure not to overwrite existing attributes.
8 $element['#attributes']['class'][] = 'myclass';