You are here

function theme_clock_option in Clock 7.2

Returns HTML for a form option.

1 theme call to theme_clock_option()
clock_element_info in ./clock.module
Implements hook_element_info().

File

./clock.module, line 366
Display clocks on your site.

Code

function theme_clock_option($variables) {
  $element = $variables['element'];
  if (!empty($element['#value'])) {
    $value = $element['#value'];
  }
  else {

    // We use the element's key as a value. It is the last value in #parents.
    $parents = array_reverse($element['#parents']);
    $value = reset($parents);
  }
  $value = (string) $value;
  $attributes = !empty($element['#attributes']) ? $element['#attributes'] : array();

  // drupal_attributes() takes care of check_plain() for us.
  $attributes['value'] = $value;
  $value_valid = isset($element['#parent_value']) || array_key_exists('#parent_value', $element);
  $value_is_array = $value_valid && is_array($element['#parent_value']);
  if ($value_valid && (!$value_is_array && (string) $element['#parent_value'] === $value || $value_is_array && in_array($key, $element['#value']))) {
    $attributes['selected'] = 'selected';
  }
  $title = !empty($element['#title']) ? $element['#title'] : $value;
  return '<option' . drupal_attributes($attributes) . '>' . check_plain($title) . '</option>';
}