1<?php 2namespace dokuwiki\Form; 3 4/** 5 * Class TextareaElement 6 * @package dokuwiki\Form 7 */ 8class TextareaElement extends InputElement { 9 10 /** 11 * @var string the actual text within the area 12 */ 13 protected $text; 14 15 /** 16 * @param string $name The name of this form element 17 * @param string $label The label text for this element 18 */ 19 public function __construct($name, $label) { 20 parent::__construct('textarea', $name, $label); 21 } 22 23 /** 24 * Get or set the element's value 25 * 26 * This is the preferred way of setting the element's value 27 * 28 * @param null|string $value 29 * @return string|$this 30 */ 31 public function val($value = null) { 32 if($value !== null) { 33 $this->text = $value; 34 return $this; 35 } 36 return $this->text; 37 } 38 39 /** 40 * The HTML representation of this element 41 * 42 * @return string 43 */ 44 protected function mainElementHTML() { 45 if($this->useInput) $this->prefillInput(); 46 return '<textarea ' . buildAttributes($this->attrs()) . '>' . 47 formText($this->val()) . '</textarea>'; 48 } 49 50} 51