function _webform_render_date in Webform 7.3
Same name and namespace in other branches
- 5.2 components/date.inc \_webform_render_date()
- 5 components/date.inc \_webform_render_date()
- 6.3 components/date.inc \_webform_render_date()
- 6.2 components/date.inc \_webform_render_date()
- 7.4 components/date.inc \_webform_render_date()
Implements _webform_render_component().
File
- components/
date.inc, line 119 - Webform module date component.
Code
function _webform_render_date($component, $value = NULL, $filter = TRUE) {
$node = isset($component['nid']) ? node_load($component['nid']) : NULL;
$element = array(
'#type' => 'date',
'#title' => $filter ? _webform_filter_xss($component['name']) : $component['name'],
'#title_display' => $component['extra']['title_display'] ? $component['extra']['title_display'] : 'before',
'#weight' => $component['weight'],
'#description' => $filter ? _webform_filter_descriptions($component['extra']['description'], $node) : $component['extra']['description'],
'#required' => $component['mandatory'],
'#start_date' => trim($component['extra']['start_date']),
'#end_date' => trim($component['extra']['end_date']),
'#year_textfield' => $component['extra']['year_textfield'],
'#default_value' => $filter ? _webform_filter_values($component['value'], $node, NULL, NULL, FALSE) : $component['value'],
'#timezone' => $component['extra']['timezone'],
'#process' => array(
'webform_expand_date',
),
'#theme' => 'webform_date',
'#theme_wrappers' => array(
'webform_element',
),
'#element_validate' => array(
'webform_validate_date',
),
'#translatable' => array(
'title',
'description',
),
);
if ($component['extra']['datepicker']) {
$element['#datepicker'] = TRUE;
$element['#attached'] = array(
'library' => array(
array(
'system',
'ui.datepicker',
),
),
);
}
// Set the value from Webform.
if (isset($value[0]) && $value[0] !== '') {
$value = webform_date_array($value[0], 'date');
$element['#default_value'] = $value;
}
return $element;
}