Answers for "hook_field_widget_form_alter"

0

hook_field_widget_form_alter

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';
  }
}
Posted by: Guest on January-21-2022

Browse Popular Code Answers by Language