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