Textarea.php
Go to the documentation of this file.
1<?php
11
34class Textarea extends Text
35{
39 protected $rows;
40
44 protected $cols;
45
49 protected $autogrow = false;
59 protected function setDefaults()
60 {
61 parent::setDefaults();
62
63 $this->defaults['rows'] = null;
64 $this->defaults['cols'] = null;
65 $this->defaults['autogrow'] = false;
66 }
67
73 public function __toString()
74 {
75 $label = $this->htmlLabel();
76 $marker = $this->htmlMarker();
77 $inputAttributes = $this->htmlInputAttributes();
78 $value = $this->htmlValue();
79 $rows = $this->htmlRows();
80 $cols = $this->htmlCols();
81 $wrapperAttributes = $this->htmlWrapperAttributes();
84
85 return "<p {$wrapperAttributes}>" .
86 "<label>" .
87 "<span class=\"depage-label\">{$label}{$marker}</span>" .
88 "<textarea name=\"{$this->name}\"{$inputAttributes}{$rows}{$cols}>{$value}</textarea>" .
89 "</label>" .
92 "</p>\n";
93 }
94
98 protected function htmlDataAttributes()
99 {
100 $options = array();
101 $options['autogrow'] = $this->autogrow;
102
103 $this->dataAttr['textarea-options'] = json_encode($options);
104
105 return parent::htmlDataAttributes();
106 }
107
113 protected function htmlRows()
114 {
115 return ($this->rows === null) ? "" : " rows=\"" . $this->htmlEscape($this->rows) . "\"";
116 }
122 protected function htmlCols()
123 {
124 return ($this->cols === null) ? "" : " cols=\"" . $this->htmlEscape($this->cols) . "\"";
125 }
126}
127
128/* vim:set ft=php sw=4 sts=4 fdm=marker et : */
htmlEscape($options=array())
Escapes HTML in strings and arrays of strings.
Definition Element.php:267
$value
Input elements's value.
Definition Input.php:123
$label
Input element - HTML label.
Definition Input.php:36
$errorMessage
Message that gets displayed in case of invalid input.
Definition Input.php:217
htmlHelpMessage()
Returns HTML-rendered helpMessage.
Definition Input.php:676
htmlWrapperAttributes()
Returns string of HTML attributes for element wrapper paragraph.
Definition Input.php:627
htmlMarker()
Returns elements' required-indicator.
Definition Input.php:565
$helpMessage
Extra help message.
Definition Input.php:229
htmlValue()
Returns HTML-rendered element value.
Definition Input.php:647
$marker
Input element - HTML marker text that marks required fields.
Definition Input.php:91
htmlErrorMessage()
Returns HTML-rendered error message.
Definition Input.php:657
HTML text input type.
Definition Text.php:39
htmlInputAttributes()
renders text element specific HTML attributes
Definition Text.php:159
HTML textarea element.
Definition Textarea.php:35
htmlCols()
Renders HTML cols attribute.
Definition Textarea.php:122
$autogrow
wether to autogrow textarea or not
Definition Textarea.php:49
htmlDataAttributes()
Returns dataAttr escaped as attribute string.
Definition Textarea.php:98
htmlRows()
Renders HTML rows attribute.
Definition Textarea.php:113
__toString()
Renders element to HTML.
Definition Textarea.php:73
$cols
HTML cols attribute.
Definition Textarea.php:44
setDefaults()
collects initial values across subclasses
Definition Textarea.php:59
$rows
HTML rows attribute.
Definition Textarea.php:39
Classes for HTML input-elements.
Definition Address.php:9