/**
* Implementation of hook_form_alter().
*/
function hs_taxonomy_form_alter(&$form, &$form_state, $form_id) {
// Add per-vocabulary settings for Hierarchical Select.
if ($form_id == 'taxonomy_form_vocabulary') {
require_once(drupal_get_path('module',
'hierarchical_select') .
'/includes/common.inc');
$vid = $form['vid']['#value'];
$form = $first_part;
$form['hierarchical_select_status'] =
array(
'#type' => 'checkbox',
'#title' =>
t('Use the Hierarchical Select form element for this vocabulary.'),
'#default_value' =>
variable_get("taxonomy_hierarchical_select_$vid",
0),
'When checked, the %free_tagging and %multiple_values settings will
be managed by the Hierarchical Select configuration.',
'%free_tagging' =>
t('Free tagging'),
'%multiple_values' =>
t('Multiple values'),
)
),
);
// Add the Hierarchical Select config form.
$module = 'hs_taxonomy';
'vid' => $vid,
'exclude_tid' => NULL,
);
$config_id = "taxonomy-$vid";
// Enable the save_lineage setting by default if the multiple parents
// vocabulary option is enabled.
'save_lineage' => (int) ($vocabulary->hierarchy == 2),
'max_levels' => _hs_taxonomy_hierarchical_select_get_depth($vid),
),
);
'hierarchy' =>
t('vocabulary'),
'hierarchies' =>
t('vocabularies'),
'item_type' =>
t('term type'),
'entities' =>
t('nodes'),
);
$max_hierarchy_depth = _hs_taxonomy_hierarchical_select_get_depth($vid);
$preview_is_required = $vocabulary->required;
$form['hierarchical_select'] = hierarchical_select_common_config_form($module, $params, $config_id, $defaults, $strings, $max_hierarchy_depth, $preview_is_required);
// The forum selection requires that only the deepest term is saved!
// See http://drupal.org/node/241766#comment-808464.
$form['hierarchical_select']['save_lineage']['#value'] = 0;
$form['hierarchical_select']['save_lineage']['#attributes'] =
array('disabled' =>
'disabled');
$form['hierarchical_select']['save_lineage']['#description'] .= '<br />'. t(
'This is the vocabulary that will be used for forum navigation and it
<strong>always</strong> requires the %dont_save_lineage setting to be
set!',
array('%dont_save_lineage' =>
t('Save only the deepest term'))
);
}
// Add the the submit handler for the Hierarchical Select config form.
$parents =
array('hierarchical_select');
$form['#submit'][] = 'hierarchical_select_common_config_form_submit';
$form['#hs_common_config_form_parents'] = $parents;
// Add a validate callback to override the freetagging and multiple select
// settings if necessary.
$form['#validate'][] = 'hierarchical_select_taxonomy_form_vocabulary_validate';
$form['#submit'][] = 'hierarchical_select_taxonomy_form_vocabulary_submit';
// The original #submit callback(s) has/have to be executed afterwards.
$form['#submit'] =
array_merge($form['#submit'],
$second_part['#submit']);
$form += $second_part;
}
}