taxonomy_form_vocabulary($form, &$form_state, $edit = array())Display form for adding and editing vocabularies.
taxonomy_form_vocabulary_submit()
modules/taxonomy/taxonomy.admin.inc, line 96
<?php
function taxonomy_form_vocabulary($form, &$form_state, $edit = array()) {
if (!is_array($edit)) {
$edit = (array)$edit;
}
$edit += array(
'name' => '',
'machine_name' => '',
'description' => '',
'hierarchy' => 0,
'weight' => 0,
);
$form['#vocabulary'] = (object) $edit;
// Check whether we need a deletion confirmation form.
if (isset($form_state['confirm_delete']) && isset($form_state['values']['vid'])) {
return taxonomy_vocabulary_confirm_delete($form, $form_state, $form_state['values']['vid']);
}
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => $edit['name'],
'#maxlength' => 255,
'#required' => TRUE,
'#field_suffix' => ' <small id="edit-name-suffix"> </small>',
);
$js_settings = array(
'type' => 'setting',
'data' => array(
'machineReadableValue' => array(
'name' => array(
'text' => t('Machine name'),
'target' => 'machine-name',
'searchPattern' => '[^a-z0-9]+',
'replaceToken' => '_',
),
),
),
);
$form['machine_name'] = array(
'#type' => 'textfield',
'#title' => t('Machine-readable name'),
'#default_value' => $edit['machine_name'],
'#maxlength' => 255,
'#description' => t('The unique machine-readable name for this vocabulary, used for theme templates. Can only contain lowercase letters, numbers, and underscores.'),
'#required' => TRUE,
'#attached' => array(
'js' => array(drupal_get_path('module', 'system') . '/system.js', $js_settings),
),
);
$form['description'] = array(
'#type' => 'textfield',
'#title' => t('Description'),
'#default_value' => $edit['description'],
);
// 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',
);
$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;
}
?>