function _webform_render_email in Webform 6.3
Same name and namespace in other branches
- 5.2 components/email.inc \_webform_render_email()
- 5 components/email.inc \_webform_render_email()
- 6.2 components/email.inc \_webform_render_email()
- 7.4 components/email.inc \_webform_render_email()
- 7.3 components/email.inc \_webform_render_email()
Implements _webform_render_component().
File
- components/
email.inc, line 113 - Webform module email component.
Code
function _webform_render_email($component, $value = NULL, $filter = TRUE) {
global $user;
$node = isset($component['nid']) ? node_load($component['nid']) : NULL;
$element = array(
'#type' => 'webform_email',
'#title' => $filter ? _webform_filter_xss($component['name']) : $component['name'],
'#title_display' => $component['extra']['title_display'] ? $component['extra']['title_display'] : 'before',
'#default_value' => $filter ? _webform_filter_values($component['value'], $node) : $component['value'],
'#required' => $component['mandatory'],
'#weight' => $component['weight'],
'#description' => $filter ? _webform_filter_descriptions($component['extra']['description'], $node) : $component['extra']['description'],
'#attributes' => $component['extra']['attributes'],
'#element_validate' => array(
'_webform_validate_email',
),
'#theme_wrappers' => array(
'webform_element_wrapper',
),
'#pre_render' => array(
'webform_element_title_display',
),
'#post_render' => array(
'webform_element_wrapper',
),
'#translatable' => array(
'title',
'description',
),
);
// Add an e-mail class for identifying the difference from normal textfields.
$element['#attributes']['class'] = isset($element['#attributes']['class']) ? $element['#attributes']['class'] . ' email' : 'email';
// Enforce uniqueness.
if ($component['extra']['unique']) {
$element['#element_validate'][] = 'webform_validate_unique';
}
if (isset($value)) {
$element['#default_value'] = $value[0];
}
if ($component['extra']['disabled']) {
if ($filter) {
$element['#attributes']['readonly'] = 'readonly';
}
else {
$element['#disabled'] = TRUE;
}
}
// Change the 'width' option to the correct 'size' option.
if ($component['extra']['width'] > 0) {
$element['#size'] = $component['extra']['width'];
}
return $element;
}