XOOPS  2.6.0
TextArea.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
12 namespace Xoops\Form;
13 
25 class TextArea extends Element
26 {
32  //protected $cols;
33 
39  //protected $rows;
40 
46  //private $placeholder;
47 
48 
59  public function __construct($caption, $name, $value = "", $rows = 5, $cols = 5, $placeholder = '')
60  {
61  $this->setCaption($caption);
62  $this->setAttribute('name', $name);
63  $this->setAttribute('rows', intval($rows));
64  $this->setAttribute('cols', intval($cols));
65  $this->setValue($value);
66  $this->setAttribute('placeholder', $placeholder);
67 
68  }
69 
75  public function getRows()
76  {
77  return (int) $this->getAttribute('rows');
78  }
79 
85  public function getCols()
86  {
87  return (int) $this->getAttribute('cols');
88  }
89 
95  public function getPlaceholder()
96  {
97  return (string) $this->getAttribute('placeholder');
98  }
99 
105  public function render()
106  {
107  if ($this->getCols() > $this->getMaxcols()) {
108  $maxcols = $this->getMaxcols();
109  } else {
110  $maxcols = $this->getCols();
111  }
112  $this->addAttribute('class', 'span' . $maxcols);
113 
115  return '<textarea ' . $attributes . ' ' . $this->getExtra() .' >'
116  . $this->getValue() . '</textarea>';
117  }
118 }
setValue($value)
Definition: Element.php:199
getValue($encode=false)
Definition: Element.php:180
setCaption($caption)
Definition: Element.php:396
__construct($caption, $name, $value="", $rows=5, $cols=5, $placeholder= '')
Definition: TextArea.php:59
setAttribute($name, $value=null)
Definition: Attributes.php:42
getExtra($encode=false)
Definition: Element.php:539
addAttribute($name, $value)
Definition: Attributes.php:117