You are here

function location_taxonomize_field_attach_form in Location Taxonomize 7.2

Implements hook_field_attach_form().

  • hides the term reference field if necessary

File

./location_taxonomize.module, line 53

Code

function location_taxonomize_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {

  // get the fields on this form, or quit if there are none
  if (isset($form_state['field'])) {
    $fields = $form_state['field'];
  }
  else {
    return;
  }

  // check if we are configured to hide the field
  $settings = location_taxonomize_get_settings();
  if ($settings['hide_terms_field']) {

    // hide the term references field if it's there
    $field_name = 'field_' . LT_TERM_ATTACH_FIELD;
    if (in_array($field_name, array_keys($fields))) {
      $form[$field_name]['#access'] = FALSE;
    }
  }
}