function cshs_field_widget_settings_form in Client-side Hierarchical Select 7
Implements hook_field_widget_settings_form().
Provide a widget settings-form.
File
- ./
cshs.module, line 82 - A simple clientside hierarchical select widget for taxonomy terms.
Code
function cshs_field_widget_settings_form($field, $instance) {
$widget = $instance['widget'];
$settings = $widget['settings'];
$form = array();
$form['cshs'] = array(
'#type' => 'fieldset',
'#title' => 'Clientside hierarchical select settings',
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#tree' => TRUE,
);
$form['cshs']['force_deepest'] = array(
'#type' => 'checkbox',
'#title' => t('Force selection of deepest level'),
'#description' => t('If checked the user will be forced to select terms from the deepest level.'),
'#default_value' => empty($settings['cshs']['force_deepest']) ? FALSE : $settings['cshs']['force_deepest'],
);
$options[0] = '---';
// TODO this might break with huge vocs.
$voc = taxonomy_vocabulary_machine_name_load($field['settings']['allowed_values'][0]['vocabulary']);
if (isset($voc)) {
foreach (taxonomy_get_tree($voc->vid) as $term) {
$options[$term->tid] = str_repeat('- ', $term->depth) . $term->name;
}
}
$form['cshs']['parent'] = array(
'#type' => 'select',
'#title' => t('Parent'),
'#description' => t('Select a parent term to use only a subtree of a vocabulary for this field.'),
'#options' => $options,
'#default_value' => !empty($settings['cshs']['parent']) ? $settings['cshs']['parent'] : 0,
);
$form['cshs']['level_labels'] = array(
'#type' => 'textfield',
'#title' => t('Labels per hierarchy-level'),
'#description' => t('Enter labels for each hierarchy-level separated by comma.'),
'#default_value' => !empty($settings['cshs']['level_labels']) ? $settings['cshs']['level_labels'] : '',
);
return $form;
}