function theme_clock_select in Clock 7.2
Returns HTML for a select form element.
Allows to use dedicated #option elements as options.
See also
File
- ./
clock.module, line 322 - Display clocks on your site.
Code
function theme_clock_select(&$variables) {
$element = $variables['element'];
element_set_attributes($element, array(
'id',
'name',
'size',
));
_form_set_class($element, array(
'form-select',
));
// form_select_options() assumes #options to be set.
$element += array(
'#options' => array(),
);
$options = form_select_options($element);
foreach (element_children($element, TRUE) as $child) {
if ($element[$child]['#type'] && ($element[$child]['#type'] == 'option' || $element[$child]['#type'] == 'optgroup')) {
if (isset($element[$child]['#description'])) {
$element['#child_descriptions'][$child] = array(
'#description' => $element[$child]['#description'],
);
}
// We need to pass the parent value in order to determine whether an
// option is selected or not.
// @see form_select_options()
if (isset($element['#value']) || array_key_exists('#value', $element)) {
$element[$child]['#parent_value'] = $element['#value'];
}
$options .= drupal_render($element[$child]);
}
}
$output = '<select' . drupal_attributes($element['#attributes']) . '>' . $options . '</select>';
if (!empty($element['#child_descriptions'])) {
$element['#child_descriptions']['#attributes']['class'][] = 'child-descriptions';
$output .= '<span' . drupal_attributes($element['#child_descriptions']['#attributes']) . '>';
foreach (element_children($element['#child_descriptions']) as $child) {
$child_element = $element['#child_descriptions'][$child];
$child_element['#attributes']['class'][] = 'description';
$child_element['#attributes']['class'][] = 'child-description';
$child_element['#attributes']['class'][] = "child-description-{$child}";
$output .= '<span' . drupal_attributes($child_element['#attributes']) . '>' . $child_element['#description'] . '</span>';
}
$output .= '</span>';
}
return $output;
}