form_textarea

Definition

form_textarea($title, $name, $value, $cols, $rows, $description = NULL, $attributes = NULL, $required = FALSE)
includes/common.inc, line 1276

Description

Format a multiple-line text field.

Parameters

$title The label for the text field.

$name The internal name used to refer to the field.

$value The initial value for the field at page load time.

$cols The width of the field, in columns of text.

$rows The height of the field, in rows of text.

$description Explanatory text to display after the form item.

$attributes An associative array of HTML attributes to add to the form item.

$required Whether the user must enter some text in the field.

Return value

A themed HTML string representing the field.

Related topics

Namesort iconDescription
Form generationFunctions to enable output of HTML forms and form elements.
Input validationFunctions to validate user input.

Code

<?php
function form_textarea($title, $name, $value, $cols, $rows, $description = NULL, $attributes = NULL, $required = FALSE) {
  $pre = '';
  $post = '';

  // optionally plug in a WYSIWYG editor
  foreach (module_list() as $module_name) {
    if (module_hook($module_name, 'textarea')) {
      $pre  .= module_invoke($module_name, 'textarea', 'pre', $name);
      $post .= module_invoke($module_name, 'textarea', 'post', $name);
    }
  }

  return theme('form_element', $title, $pre .'<textarea wrap="virtual" cols="'. check_plain($cols) .'" rows="'. check_plain($rows) .'" name="edit['. $name .']" id="edit-'. $name .'" class="'. _form_get_class('textarea', $required, _form_get_error($name)) .'"'. drupal_attributes($attributes) .'>'. check_plain($value) .'</textarea>'. $post, $description, 'edit-'. $name, $required, _form_get_error($name));
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.