You are here

function _webform_render_textarea in Webform 6.3

Same name and namespace in other branches
  1. 5.2 components/textarea.inc \_webform_render_textarea()
  2. 5 components/textarea.inc \_webform_render_textarea()
  3. 6.2 components/textarea.inc \_webform_render_textarea()
  4. 7.4 components/textarea.inc \_webform_render_textarea()
  5. 7.3 components/textarea.inc \_webform_render_textarea()

Implements _webform_render_component().

File

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

Code

function _webform_render_textarea($component, $value = NULL, $filter = TRUE) {
  $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_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'],
    '#rows' => !empty($component['extra']['rows']) ? $component['extra']['rows'] : 5,
    '#cols' => !empty($component['extra']['cols']) ? $component['extra']['cols'] : 60,
    '#attributes' => $component['extra']['attributes'],
    '#resizable' => (bool) $component['extra']['resizable'],
    // MUST be FALSE to disable.
    '#theme_wrappers' => array(
      'webform_element_wrapper',
    ),
    '#pre_render' => array(
      'webform_element_title_display',
    ),
    '#post_render' => array(
      'webform_element_wrapper',
    ),
    '#translatable' => array(
      'title',
      'description',
    ),
  );
  if ($component['extra']['disabled']) {
    if ($filter) {
      $element['#attributes']['readonly'] = 'readonly';
    }
    else {
      $element['#disabled'] = TRUE;
    }
  }
  if (isset($value)) {
    $element['#default_value'] = $value[0];
  }
  return $element;
}