You are here

function _features_form_taxonomy_form_vocabulary_alter in Features 6

See also

features_form_taxonomy_form_vocabulary_alter().

1 call to _features_form_taxonomy_form_vocabulary_alter()
features_form_taxonomy_form_vocabulary_alter in ./features.module
Targeted form_alter for vocabulary edit pages.

File

includes/features.taxonomy.inc, line 112

Code

function _features_form_taxonomy_form_vocabulary_alter(&$form, &$form_state) {
  $elem = array(
    '#type' => 'textfield',
    '#title' => t('Machine name'),
    '#description' => t('A system name for this vocabulary, may not be changed once it has been set.'),
  );
  if (!isset($form['module']) || $form['module']['#value'] == 'taxonomy') {

    // This vocabulary is new or wasn't assigned a machine name.
    $elem['#element_validate'] = array(
      'features_taxonomy_machine_name_validate',
    );
    unset($form['module']);
  }
  elseif (strpos($form['module']['#value'], 'features_') === 0) {

    // Simply display the existing machine name if we have one.
    $elem['#disabled'] = true;
    $elem['#value'] = substr($form['module']['#value'], 9);
  }
  else {

    // Some other module is responsible here, do nothing.
    return;
  }

  // Position the machine name right after the vocab name without interfering
  // with any explicit weights.
  $new = array();
  foreach ($form['identification'] as $k => $v) {
    $new[$k] = $v;
    if ($k == 'name') {
      $new['module'] = $elem;
    }
  }
  $form['identification'] = $new;
}