Merge pull request #4112 from dokuwiki/bot/autofix
[dokuwiki.git] / inc / Form / TextareaElement.php
blob7f515bbdb877421de6c4b60d0e2b2e64465c91c7
1 <?php
3 namespace dokuwiki\Form;
5 /**
6 * Class TextareaElement
7 * @package dokuwiki\Form
8 */
9 class TextareaElement extends InputElement
11 /**
12 * @var string the actual text within the area
14 protected $text;
16 /**
17 * @param string $name The name of this form element
18 * @param string $label The label text for this element
20 public function __construct($name, $label)
22 parent::__construct('textarea', $name, $label);
23 $this->attr('dir', 'auto');
26 /**
27 * Get or set the element's value
29 * This is the preferred way of setting the element's value
31 * @param null|string $value
32 * @return string|$this
34 public function val($value = null)
36 if ($value !== null) {
37 $this->text = cleanText($value);
38 return $this;
40 return $this->text;
43 /**
44 * The HTML representation of this element
46 * @return string
48 protected function mainElementHTML()
50 if ($this->useInput) $this->prefillInput();
51 return '<textarea ' . buildAttributes($this->attrs()) . '>' .
52 formText($this->val()) . '</textarea>';