Debian Codegraph @

vendor/oojs/oojs-ui/php/widgets/MultilineTextInputWidget.php

raw
1 <?php
2
3 namespace OOUI;
4
5 /**
6 * Input widget with a text field.
7 */
8 class MultilineTextInputWidget extends TextInputWidget {
9
10 /**
11 * Allow multiple lines of text.
12 *
13 * @var bool
14 */
15 protected $multiline = true;
16
17 /**
18 * @param array $config Configuration options
19 * - int $config['rows'] Number of visible lines in textarea.
20 */
21 public function __construct( array $config = [] ) {
22 // Config initialization
23 $config = array_merge( [
24 'readOnly' => false,
25 'autofocus' => false,
26 'required' => false,
27 ], $config );
28
29 // Parent constructor
30 parent::__construct( $config );
31
32 if ( $config['rows'] ?? null ) {
33 $this->input->setAttributes( [ 'rows' => $config['rows'] ] );
34 }
35 }
36
37 /** @inheritDoc */
38 protected function getInputElement( $config ) {
39 return new Tag( 'textarea' );
40 }
41
42 /** @inheritDoc */
43 public function getConfig( &$config ) {
44 $rows = $this->input->getAttribute( 'rows' );
45 if ( $rows !== null ) {
46 $config['rows'] = $rows;
47 }
48 return parent::getConfig( $config );
49 }
50 }