You are here

function chosen_field_widget_form_alter in Chosen 7.3

Same name and namespace in other branches
  1. 8.2 chosen.module \chosen_field_widget_form_alter()
  2. 6 chosen.module \chosen_field_widget_form_alter()
  3. 7 chosen.module \chosen_field_widget_form_alter()
  4. 7.2 chosen.module \chosen_field_widget_form_alter()
  5. 3.0.x chosen.module \chosen_field_widget_form_alter()

Implements hook_field_widget_form_alter().

TODO: This needs to be improved. This is maybe not the correct way. TODO: When we replace the CHOSEN_WIDGETS constant we have to adjust this function.

File

./chosen.module, line 237
General functions and hook implementations.

Code

function chosen_field_widget_form_alter(&$element, &$form_state, $context) {
  $type = $context['instance']['widget']['type'];
  if (in_array($type, unserialize(CHOSEN_WIDGETS))) {
    $settings = $context['instance']['widget']['settings'];
    if (!empty($settings['apply_chosen'])) {
      $element['#attributes']['class'][] = 'chosen-widget';
    }
  }
}