You are here

function termcase_form_taxonomy_form_vocabulary_alter in Termcase 7

Implements hook_form_FORM_ID_alter().

Adds the termcase selection dropdown to the vocabulary form.

File

./termcase.module, line 51
The Termcase module gives you the option to specify specific case-formatting on terms.

Code

function termcase_form_taxonomy_form_vocabulary_alter(&$form, &$form_state) {
  $vocabulary = $form['#vocabulary'];
  $mode = TERMCASE_NONE;
  if (!empty($vocabulary->machine_name)) {
    $mode = _termcase_vocabulary_termcase($vocabulary->machine_name);
  }
  $form['termcase'] = array(
    '#title' => t('Term case settings'),
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#weight' => 2,
    'termcase_options' => array(
      '#title' => t('Convert terms to this case'),
      '#type' => 'select',
      '#options' => array(
        TERMCASE_NONE => t('No conversion'),
        TERMCASE_UCFIRST => t('Convert the first character to uppercase'),
        TERMCASE_LOWERCASE => t('Convert all characters to lowercase'),
        TERMCASE_UPPERCASE => t('Convert ALL CHARACTERS TO UPPERCASE'),
        TERMCASE_PROPERCASE => t('Convert the first character of each word to uppercase'),
      ),
      '#default_value' => $mode,
      '#description' => t('This applies to all terms that are added to this vocabulary.'),
    ),
  );
  $form['submit']['#weight'] = 4;

  // These settings only apply on existing vocabularies.
  if (isset($form['vid'])) {
    $form['delete']['#weight'] = 5;
    $form['termcase']['termcase_options']['#description'] = t('Note: existing terms will not be changed.');
    $form['termcase']['termcase_update_terms'] = array(
      '#title' => t('Convert the existing terms in this vocabulary immediately'),
      '#type' => 'checkbox',
    );
  }
}