You are here

function theme_webform_time in Webform 7.4

Same name and namespace in other branches
  1. 5.2 components/time.inc \theme_webform_time()
  2. 5 components/time.inc \theme_webform_time()
  3. 6.3 components/time.inc \theme_webform_time()
  4. 6.2 components/time.inc \theme_webform_time()
  5. 7.3 components/time.inc \theme_webform_time()

Theme a webform time element.

1 theme call to theme_webform_time()
_webform_render_time in components/time.inc
Implements _webform_render_component().

File

components/time.inc, line 279
Webform module time component.

Code

function theme_webform_time($variables) {
  $element = $variables['element'];
  $element['hour']['#attributes']['class'][] = 'hour';
  $element['minute']['#attributes']['class'][] = 'minute';

  // Add error classes to all items within the element.
  if (form_get_error($element)) {
    $element['hour']['#attributes']['class'][] = 'error';
    $element['minute']['#attributes']['class'][] = 'error';
  }

  // Add HTML5 required attribute, if needed.
  if ($element['#required']) {
    $element['hour']['#attributes']['required'] = 'required';
    $element['minute']['#attributes']['required'] = 'required';
    if (!empty($element['ampm'])) {
      $element['ampm']['am']['#attributes']['required'] = 'required';
      $element['ampm']['pm']['#attributes']['required'] = 'required';
    }
  }
  $output = '<div class="webform-container-inline">' . drupal_render($element['hour']) . drupal_render($element['minute']) . drupal_render($element['ampm']) . '</div>';
  return $output;
}