You are here

function term_level_field_settings_form in Term Level Field 7

Implements hook_field_settings_form().

File

./term_level.module, line 167
Field type for referencing terms with a level to an entity.

Code

function term_level_field_settings_form($field, $instance, $has_data) {
  $vocabularies = taxonomy_get_vocabularies();
  $options = array();
  foreach ($vocabularies as $vocabulary) {
    $options[$vocabulary->machine_name] = $vocabulary->name;
  }
  $form['voc'] = array(
    '#type' => 'select',
    '#title' => t('Vocabulary'),
    '#default_value' => $field['settings']['voc'],
    '#options' => $options,
    '#required' => TRUE,
    '#description' => t('The vocabulary which supplies the options for this field. The vocabulary structure either needs to be a flat list or a two-level hierarchy, where the terms get grouped by their parents in the first level.'),
    '#disabled' => $has_data,
  );
  $form['levels'] = array(
    '#type' => 'textarea',
    '#title' => t('Levels'),
    '#default_value' => $field['settings']['levels'],
    '#required' => TRUE,
    '#description' => t('Specify the term levels for this field. Enter one level per line, in the format level-key|level-label (level-key must be numeric).'),
    '#element_validate' => array(
      'term_level_field_settings_levels_validate',
    ),
    '#disabled' => $has_data,
  );
  return $form;
}