Theming Hierarchical select Element which you have added to your FAPI or CCK.
function <<themename>>_hierarchical_select_form_element($element, $value) {
$output = '<div class="form-item hierarchical-select-wrapper-wrapper"';
if (!empty($element['#id'])) {
$output .= ' id="'. $element['#id'] .'-wrapper"';
}
$output .= ">\n";
$required = !empty($element['#required']) ? '<span class="form-required" title="'. t('This field is required.') .'">*</span>' : '';
if (!empty($element['#title'])) {
$title = $element['#title'];
if (!empty($element['#id'])) {
$output .= ' <label for="'. $element['#id'] .'">'. t('!required !title', array('!title' => filter_xss_admin($title), '!required' => $required)) ."</label>\n";
}
else {
$output .= ' <label>'. t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) ."</label>\n";
// $output .= ' <label for="'. $element['#id'] .'">'. t('!required !title', array('!title' => filter_xss_admin($title), '!required' => $required)) ."</label>\n";
}
}
$output .= " $value\n";
if (!empty($element['#description'])) {
$output .= ' <div class="description">'. $element['#description'] ."</div>\n";
}
$output .= "</div>\n";
return $output;
}
Copy the above code to your template.php and tweak it !!!!
Hierarchical Select Doesn't Support label for second drop down which coming out on your select.
To have one.. try this code
Else part will add Label to second Drop Down
function <<themename>>_hierarchical_select_select($element) {
$select = '';
$size = $element['#size'] ? ' size="'. $element['#size'] .'"' : '';
$class = array('form-select');
if (form_get_error($element) === '') {
$class = array_merge($class, array('error'));
}
_form_set_class($element, $class);
$multiple = isset($element['#multiple']) && $element['#multiple'];
if ($element['#id']=='<<Parent Hierarchical Element ID>>') {
$label = '';
}
else
{
$label = '<label for="hierarchical-select-16-wrapper"><span title="This field is required." class="form-required">*</span> States</label>';
}
return $label.'<select name="'. $element['#name'] .''. ($multiple ? '[]' : '') .'"'. ($multiple ? ' multiple="multiple" ' : '') . drupal_attributes($element['#attributes']) .' id="'. $element['#id'] .'" '. $size .'>'. _hierarchical_select_options($element) .'</select>';
}
If you find an easier way to do this..pls do comment.. Thanks :)
Sowmi