You are here

function select2_field_widget_entityreference_autocomplete_base_form_alter in Select 2 7

2 calls to select2_field_widget_entityreference_autocomplete_base_form_alter()
select2_field_widget_entityreference_autocomplete_form_alter in ./select2.module
select2_field_widget_entityreference_autocomplete_tags_form_alter in ./select2.module

File

./select2.module, line 593
Main file for Select2 module.

Code

function select2_field_widget_entityreference_autocomplete_base_form_alter(&$element, &$form_state, $context) {
  if (isset($element['target_id'])) {
    $target_element =& $element['target_id'];
  }
  else {
    $target_element =& $element;
  }
  if (isset($target_element['#field_name']) && $target_element['#field_name']) {
    $field_info = field_info_field($target_element['#field_name']);
    $target_element['#field_info'] = $field_info;
    $field_instance = field_info_instance($target_element['#entity_type'], $target_element['#field_name'], $target_element['#bundle']);
    $target_element['#field_instance'] = $field_instance;
    if (isset($field_instance['settings']['select2_integration']) && $field_instance['settings']['select2_integration']) {
      $select2_settings = $field_instance['settings']['select2_integration'];
      if (isset($select2_settings['hide_id']) && $select2_settings['hide_id']) {
        $target_element['#select2_defaults']['hideEntityIds'] = TRUE;
      }
    }
  }
}