function taxonomy_form_vocabulary in Drupal 4
Same name and namespace in other branches
- 5 modules/taxonomy/taxonomy.module \taxonomy_form_vocabulary()
- 6 modules/taxonomy/taxonomy.admin.inc \taxonomy_form_vocabulary()
- 7 modules/taxonomy/taxonomy.admin.inc \taxonomy_form_vocabulary()
Display form for adding and editing vocabularies.
1 call to taxonomy_form_vocabulary()
- taxonomy_admin_vocabulary_edit in modules/
taxonomy.module - Page to add or edit a vocabulary
1 string reference to 'taxonomy_form_vocabulary'
- forum_form_alter in modules/
forum.module - Implementation of hook_form_alter().
File
- modules/
taxonomy.module, line 187 - Enables the organization of content into categories.
Code
function taxonomy_form_vocabulary($edit = array()) {
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Vocabulary name'),
'#default_value' => $edit['name'],
'#maxlength' => 64,
'#description' => t('The name for this vocabulary. Example: "Topic".'),
'#required' => TRUE,
);
$form['description'] = array(
'#type' => 'textarea',
'#title' => t('Description'),
'#default_value' => $edit['description'],
'#description' => t('Description of the vocabulary; can be used by modules.'),
);
$form['help'] = array(
'#type' => 'textfield',
'#title' => t('Help text'),
'#default_value' => $edit['help'],
'#description' => t('Instructions to present to the user when choosing a term.'),
);
$form['nodes'] = array(
'#type' => 'checkboxes',
'#title' => t('Types'),
'#default_value' => $edit['nodes'],
'#options' => node_get_types(),
'#description' => t('A list of node types you want to associate with this vocabulary.'),
'#required' => TRUE,
);
$form['hierarchy'] = array(
'#type' => 'radios',
'#title' => t('Hierarchy'),
'#default_value' => $edit['hierarchy'],
'#options' => array(
t('Disabled'),
t('Single'),
t('Multiple'),
),
'#description' => t('Allows <a href="%help-url">a tree-like hierarchy</a> between terms of this vocabulary.', array(
'%help-url' => url('admin/help/taxonomy', NULL, NULL, 'hierarchy'),
)),
);
$form['relations'] = array(
'#type' => 'checkbox',
'#title' => t('Related terms'),
'#default_value' => $edit['relations'],
'#description' => t('Allows <a href="%help-url">related terms</a> in this vocabulary.', array(
'%help-url' => url('admin/help/taxonomy', NULL, NULL, 'related-terms'),
)),
);
$form['tags'] = array(
'#type' => 'checkbox',
'#title' => t('Free tagging'),
'#default_value' => $edit['tags'],
'#description' => t('Content is categorized by typing terms instead of choosing from a list.'),
);
$form['multiple'] = array(
'#type' => 'checkbox',
'#title' => t('Multiple select'),
'#default_value' => $edit['multiple'],
'#description' => t('Allows nodes to have more than one term from this vocabulary (always true for free tagging).'),
);
$form['required'] = array(
'#type' => 'checkbox',
'#title' => t('Required'),
'#default_value' => $edit['required'],
'#description' => t('If enabled, every node <strong>must</strong> have at least one term in this vocabulary.'),
);
$form['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight'),
'#default_value' => $edit['weight'],
'#description' => t('In listings, the heavier vocabularies will sink and the lighter vocabularies will be positioned nearer the top.'),
);
// Add extra vocabulary form elements.
$extra = module_invoke_all('taxonomy', 'form', 'vocabulary', $edit);
if (is_array($extra)) {
foreach ($extra as $key => $element) {
$extra[$key]['#weight'] = isset($extra[$key]['#weight']) ? $extra[$key]['#weight'] : -18;
}
$form = array_merge($form, $extra);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
if ($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 drupal_get_form('taxonomy_form_vocabulary', $form);
}