3 namespace Drupal\Core\Render\Element;
5 use Drupal\Core\Form\FormStateInterface;
8 * Provides a form element for input of multiple-line text.
11 * - #rows: Number of rows in the text box.
12 * - #cols: Number of columns in the text box.
13 * - #resizable: Controls whether the text area is resizable. Allowed values
14 * are "none", "vertical", "horizontal", or "both" (defaults to "vertical").
18 * $form['text'] = array(
19 * '#type' => 'textarea',
20 * '#title' => $this->t('Text'),
24 * @see \Drupal\Core\Render\Element\Textfield
25 * @see \Drupal\filter\Element\TextFormat
27 * @FormElement("textarea")
29 class Textarea extends FormElement {
34 public function getInfo() {
35 $class = get_class($this);
40 '#resizable' => 'vertical',
42 [$class, 'processAjaxForm'],
43 [$class, 'processGroup'],
46 [$class, 'preRenderGroup'],
48 '#theme' => 'textarea',
49 '#theme_wrappers' => ['form_element'],
56 public static function valueCallback(&$element, $input, FormStateInterface $form_state) {
57 if ($input !== FALSE && $input !== NULL) {
58 // This should be a string, but allow other scalars since they might be
59 // valid input in programmatic form submissions.
60 return is_scalar($input) ? (string) $input : '';