Security update for Core, with self-updated composer
[yaffs-website] / web / core / lib / Drupal / Core / Render / Element / Textarea.php
1 <?php
2
3 namespace Drupal\Core\Render\Element;
4
5 use Drupal\Core\Form\FormStateInterface;
6
7 /**
8  * Provides a form element for input of multiple-line text.
9  *
10  * Properties:
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").
15  * - #maxlength: The maximum amount of characters to accept as input.
16  *
17  * Usage example:
18  * @code
19  * $form['text'] = array(
20  *   '#type' => 'textarea',
21  *   '#title' => $this->t('Text'),
22  * );
23  * @endcode
24  *
25  * @see \Drupal\Core\Render\Element\Textfield
26  * @see \Drupal\filter\Element\TextFormat
27  *
28  * @FormElement("textarea")
29  */
30 class Textarea extends FormElement {
31
32   /**
33    * {@inheritdoc}
34    */
35   public function getInfo() {
36     $class = get_class($this);
37     return [
38       '#input' => TRUE,
39       '#cols' => 60,
40       '#rows' => 5,
41       '#resizable' => 'vertical',
42       '#process' => [
43         [$class, 'processAjaxForm'],
44         [$class, 'processGroup'],
45       ],
46       '#pre_render' => [
47         [$class, 'preRenderGroup'],
48       ],
49       '#theme' => 'textarea',
50       '#theme_wrappers' => ['form_element'],
51     ];
52   }
53
54   /**
55    * {@inheritdoc}
56    */
57   public static function valueCallback(&$element, $input, FormStateInterface $form_state) {
58     if ($input !== FALSE && $input !== NULL) {
59       // This should be a string, but allow other scalars since they might be
60       // valid input in programmatic form submissions.
61       return is_scalar($input) ? (string) $input : '';
62     }
63     return NULL;
64   }
65
66 }