<?php namespace PHPFUI\Input; class TextArea extends \PHPFUI\Input\Input { private int $rows = 10; public function __construct(string $name, string $label = '', ?string $value = '') { parent::__construct('text', $name); $this->value = $value; $this->label = $label; } public function htmlEditing(\PHPFUI\Interfaces\Page $page, \PHPFUI\Interfaces\HTMLEditor $model) : static { $id = $this->getId(); $model->updatePage($page, $id); return $this; } public function setRows(int $rows = 10) : static { $this->rows = $rows; return $this; } protected function getEnd() : string { $output = '</textarea>'; if (! empty($this->error)) { $output .= "<small class='error'>{$this->error}</small>"; } return $output; } protected function getStart() : string { $this->setAttribute('rows', (string)$this->rows); $label = new \PHPFUI\HTML5Element('label'); $label->add($this->getToolTip($this->getLabel())); if ($this->required) { $label->add(\PHPFUI\Language::$required); } $label->setAttribute('for', $this->getId()); $output = $label . '<textarea'; $output .= $this->getIdAttribute(); $output .= " name='{$this->name}'"; $this->deleteAttribute('onkeypress'); $output .= $this->getAttributes(); $output .= '>'; $output .= $this->value; return $output; } }