You are here

function _webform_render_time in Webform 7.4

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

Implements _webform_render_component().

File

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

Code

function _webform_render_time($component, $value = NULL, $filter = TRUE, $submission = NULL) {
  $node = isset($component['nid']) ? node_load($component['nid']) : NULL;
  $element = array(
    '#type' => 'webform_time',
    '#title' => $filter ? webform_filter_xss($component['name']) : $component['name'],
    '#title_display' => $component['extra']['title_display'] ? $component['extra']['title_display'] : 'before',
    '#required' => $component['required'],
    '#weight' => $component['weight'],
    '#description' => $filter ? webform_filter_descriptions($component['extra']['description'], $node) : $component['extra']['description'],
    '#element_validate' => array(
      'webform_validate_time',
    ),
    '#start_time' => trim($component['extra']['start_time']),
    '#end_time' => trim($component['extra']['end_time']),
    '#hourformat' => $component['extra']['hourformat'],
    '#minuteincrements' => $component['extra']['minuteincrements'],
    '#default_value' => $filter ? webform_replace_tokens($component['value'], $node) : $component['value'],
    '#timezone' => $component['extra']['timezone'],
    '#process' => array(
      'webform_expand_time',
    ),
    '#theme' => 'webform_time',
    '#theme_wrappers' => array(
      'webform_element',
    ),
    '#translatable' => array(
      'title',
      'description',
    ),
  );

  // Set the value from Webform if available.
  if (!empty($value[0])) {
    $element['#default_value'] = $value[0];
  }
  return $element;
}