function _webform_render_textarea in Webform 7.4
Same name and namespace in other branches
- 5.2 components/textarea.inc \_webform_render_textarea()
- 5 components/textarea.inc \_webform_render_textarea()
- 6.3 components/textarea.inc \_webform_render_textarea()
- 6.2 components/textarea.inc \_webform_render_textarea()
- 7.3 components/textarea.inc \_webform_render_textarea()
Implements _webform_render_component().
File
- components/
textarea.inc, line 109 - Webform module textarea component.
Code
function _webform_render_textarea($component, $value = NULL, $filter = TRUE, $submission = NULL) {
$node = isset($component['nid']) ? node_load($component['nid']) : NULL;
$element = array(
'#type' => 'textarea',
'#title' => $filter ? webform_filter_xss($component['name']) : $component['name'],
'#title_display' => $component['extra']['title_display'] ? $component['extra']['title_display'] : 'before',
'#default_value' => $filter ? webform_replace_tokens($component['value'], $node) : $component['value'],
'#required' => $component['required'],
'#weight' => $component['weight'],
'#description' => $filter ? webform_filter_descriptions($component['extra']['description'], $node) : $component['extra']['description'],
'#rows' => !empty($component['extra']['rows']) ? $component['extra']['rows'] : 5,
'#cols' => !empty($component['extra']['cols']) ? $component['extra']['cols'] : 60,
'#attributes' => $component['extra']['attributes'],
// MUST be FALSE to disable.
'#resizable' => (bool) $component['extra']['resizable'],
'#theme_wrappers' => array(
'webform_element',
),
'#translatable' => array(
'title',
'description',
'placeholder',
),
);
if ($component['required']) {
$element['#attributes']['required'] = 'required';
}
if ($component['extra']['placeholder']) {
$element['#attributes']['placeholder'] = $component['extra']['placeholder'];
}
if ($component['extra']['disabled']) {
if ($filter) {
$element['#attributes']['readonly'] = 'readonly';
}
else {
$element['#disabled'] = TRUE;
}
}
if (isset($value[0])) {
$element['#default_value'] = $value[0];
}
return $element;
}