1 form.inc theme_textarea($variables)

Returns HTML for a textarea form element.

Parameters

$variables: An associative array containing:

  • element: An associative array containing the properties of the element. Properties used: #title, #value, #description, #rows, #cols, #placeholder, #required, #attributes, #resizable

Related topics

File

core/includes/form.inc, line 4718
Functions for form and batch generation and processing.

Code

function theme_textarea($variables) {
  $element = $variables['element'];
  element_set_attributes($element, array('id', 'name', 'rows', 'cols', 'placeholder'));
  _form_set_class($element, array('form-textarea'));

  $wrapper_attributes = array(
    'class' => array('form-textarea-wrapper'),
  );

  // Add resizable behavior.
  if (isset($element['#resizable'])) {
    $valid_values = array('none', 'both', 'horizontal', 'vertical');
    // Transform previously used boolean value to new string value.
    if ($element['#resizable'] === TRUE) {
      $element['#resizable'] = 'vertical';
    }
    if ($element['#resizable'] === FALSE) {
      $element['#resizable'] = 'none';
    }
    if (in_array($element['#resizable'], $valid_values)) {
      $element['#attributes']['class'][] = 'resize-' . $element['#resizable'];
      if ($element['#resizable'] != 'none') {
        $wrapper_attributes['class'][] = 'resizable';
      }
    }
  }

  $output = '<div' . backdrop_attributes($wrapper_attributes) . '>';
  $output .= '<textarea' . backdrop_attributes($element['#attributes']) . '>' . check_plain($element['#value']) . '</textarea>';
  $output .= '</div>';
  return $output;
}