Same name and namespace in other branches
  1. 4.6.x modules/taxonomy.module \taxonomy_form_vocabulary()
  2. 4.7.x modules/taxonomy.module \taxonomy_form_vocabulary()
  3. 5.x modules/taxonomy/taxonomy.module \taxonomy_form_vocabulary()
  4. 7.x modules/taxonomy/taxonomy.admin.inc \taxonomy_form_vocabulary()

Display form for adding and editing vocabularies.

See also

taxonomy_form_vocabulary_submit()

Related topics

2 string references to 'taxonomy_form_vocabulary'
taxonomy_admin_vocabulary_edit in modules/taxonomy/taxonomy.admin.inc
Page to edit a vocabulary.
taxonomy_menu in modules/taxonomy/taxonomy.module
Implementation of hook_menu().

File

modules/taxonomy/taxonomy.admin.inc, line 102
Administrative page callbacks for the taxonomy module.

Code

function taxonomy_form_vocabulary(&$form_state, $edit = array()) {
  $edit += array(
    'name' => '',
    'description' => '',
    'help' => '',
    'nodes' => array(),
    'hierarchy' => 0,
    'relations' => 0,
    'tags' => 0,
    'multiple' => 0,
    'required' => 0,
    'weight' => 0,
  );
  $form['identification'] = array(
    '#type' => 'fieldset',
    '#title' => t('Identification'),
    '#collapsible' => TRUE,
  );
  $form['identification']['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Vocabulary name'),
    '#default_value' => $edit['name'],
    '#maxlength' => 255,
    '#description' => t('The name for this vocabulary, e.g., <em>"Tags"</em>.'),
    '#required' => TRUE,
  );
  $form['identification']['description'] = array(
    '#type' => 'textarea',
    '#title' => t('Description'),
    '#default_value' => $edit['description'],
    '#description' => t('Description of the vocabulary; can be used by modules.'),
  );
  $form['identification']['help'] = array(
    '#type' => 'textfield',
    '#title' => t('Help text'),
    '#maxlength' => 255,
    '#default_value' => $edit['help'],
    '#description' => t('Instructions to present to the user when selecting terms, e.g., <em>"Enter a comma separated list of words"</em>.'),
  );
  $form['content_types'] = array(
    '#type' => 'fieldset',
    '#title' => t('Content types'),
    '#collapsible' => TRUE,
  );
  $form['content_types']['nodes'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Content types'),
    '#default_value' => $edit['nodes'],
    '#options' => array_map('check_plain', node_get_types('names')),
    '#description' => t('Select content types to categorize using this vocabulary.'),
  );
  $form['settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Settings'),
    '#collapsible' => TRUE,
  );
  $form['settings']['tags'] = array(
    '#type' => 'checkbox',
    '#title' => t('Tags'),
    '#default_value' => $edit['tags'],
    '#description' => t('Terms are created by users when submitting posts by typing a comma separated list.'),
  );
  $form['settings']['multiple'] = array(
    '#type' => 'checkbox',
    '#title' => t('Multiple select'),
    '#default_value' => $edit['multiple'],
    '#description' => t('Allows posts to have more than one term from this vocabulary (always true for tags).'),
  );
  $form['settings']['required'] = array(
    '#type' => 'checkbox',
    '#title' => t('Required'),
    '#default_value' => $edit['required'],
    '#description' => t('At least one term in this vocabulary must be selected when submitting a post.'),
  );
  $form['settings']['weight'] = array(
    '#type' => 'weight',
    '#title' => t('Weight'),
    '#default_value' => $edit['weight'],
    '#description' => t('Vocabularies are displayed in ascending order by weight.'),
  );

  // Set the hierarchy to "multiple parents" by default. This simplifies the
  // vocabulary form and standardizes the term form.
  $form['hierarchy'] = array(
    '#type' => 'value',
    '#value' => '0',
  );

  // Enable "related terms" by default.
  $form['relations'] = array(
    '#type' => 'value',
    '#value' => '1',
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  if (isset($edit['vid'])) {
    $form['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete'),
    );
    $form['vid'] = array(
      '#type' => 'value',
      '#value' => $edit['vid'],
    );
    $form['module'] = array(
      '#type' => 'value',
      '#value' => $edit['module'],
    );
  }
  return $form;
}