function hs_taxonomy_form_taxonomy_form_term_alter in Hierarchical Select 6.3
Same name and namespace in other branches
- 7.3 modules/hs_taxonomy.module \hs_taxonomy_form_taxonomy_form_term_alter()
File
- modules/
hs_taxonomy.module, line 119 - Implementation of the Hierarchical Select API for the Taxonomy module.
Code
function hs_taxonomy_form_taxonomy_form_term_alter(&$form, &$form_state) {
// Don't alter the form when it's in confirmation mode.
if (isset($form_state['confirm_delete']) || isset($form_state['confirm_parents'])) {
return;
}
require_once drupal_get_path('module', 'hierarchical_select') . '/includes/common.inc';
// Build an appropriate config, that inherits the level_labels settings
// from the vocabulary's Hierarchical Select config.
$vid = $form['#vocabulary']['vid'];
$vocabulary_config = hierarchical_select_common_config_get("taxonomy-{$vid}");
$config = array(
'module' => 'hs_taxonomy',
'params' => array(
'vid' => $vid,
'exclude_tid' => $form['#term']['tid'],
),
'enforce_deepest' => 0,
'save_lineage' => 0,
'level_labels' => $vocabulary_config['level_labels'],
'dropbox' => array(
'status' => 1,
),
'params' => array(
'vid' => isset($form['vid']['#value']) ? $form['vid']['#value'] : NULL,
'exclude_tid' => isset($form['tid']['#value']) ? $form['tid']['#value'] : NULL,
'root_term' => TRUE,
),
);
// Use Hierarchical Select for selecting the parent term(s).
$parent = isset($form['tid']['#value']) ? array_keys(taxonomy_get_parents($form['tid']['#value'])) : array();
$form['advanced']['parent'] = array(
'#type' => 'hierarchical_select',
'#config' => $config,
// Copied from core.
'#title' => t('Parents'),
'#description' => t('Parent terms') . '.',
'#weight' => -15,
'#default_value' => $parent,
);
$form['advanced']['parent']['#config']['dropbox']['title'] = t('All parent terms');
// Use Hierarchical Select for selecting the related term(s).
$related = isset($form['tid']['#value']) ? array_keys(taxonomy_get_related($form['tid']['#value'])) : array();
$form['advanced']['relations'] = array(
'#type' => 'hierarchical_select',
'#config' => $config,
// Copied from core.
'#title' => t('Related terms'),
'#weight' => -15,
'#default_value' => $related,
);
$form['advanced']['relations']['#config']['dropbox']['title'] = t('All related terms');
}