You are here

function _webform_render_time in Webform 6.3

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.2 components/time.inc \_webform_render_time()
  4. 7.4 components/time.inc \_webform_render_time()
  5. 7.3 components/time.inc \_webform_render_time()

Implements _webform_render_component().

File

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

Code

function _webform_render_time($component, $value = NULL, $filter = TRUE) {
  $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['mandatory'],
    '#weight' => $component['weight'],
    '#description' => $filter ? _webform_filter_descriptions($component['extra']['description'], $node) : $component['extra']['description'],
    '#element_validate' => array(
      'webform_validate_time',
    ),
    '#hourformat' => $component['extra']['hourformat'],
    '#minuteincrements' => $component['extra']['minuteincrements'],
    '#default_value' => $filter ? _webform_filter_values($component['value'], $node, NULL, NULL, FALSE) : $component['value'],
    '#timezone' => $component['extra']['timezone'],
    '#process' => array(
      'webform_expand_time',
    ),
    '#theme' => 'webform_time',
    '#theme_wrappers' => array(
      'webform_element_wrapper',
    ),
    '#pre_render' => array(
      'webform_element_title_display',
    ),
    '#post_render' => array(
      'webform_element_wrapper',
    ),
    '#translatable' => array(
      'title',
      'description',
    ),
  );

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