Alter forms for field widgets provided by other modules.
$element: The field widget form element as constructed by hook_field_widget_form().
$form_state: An associative array containing the current state of the form.
$context: An associative array containing the following key-value pairs, matching the arguments received by hook_field_widget_form():
hook_field_widget_WIDGET_TYPE_form_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
function hook_field_widget_form_alter(&$element, &$form_state, $context) {
// Add a css class to widget form elements for all fields of type mytype.
if ($context['field']['type'] == 'mytype') {
// Be sure not to overwrite existing attributes.
$element['#attributes']['class'][] = 'myclass';
}
}