depage-forms
v2.0.0
html forms made easy
Toggle main menu visibility
Loading...
Searching...
No Matches
Textarea.php
Go to the documentation of this file.
1
<?php
2
10
11
namespace
Depage\HtmlForm\Elements;
12
35
class
Textarea
extends
Text
36
{
40
protected
$rows
;
41
45
protected
$cols
;
46
50
protected
$autogrow
=
false
;
60
protected
function
setDefaults
(): void
61
{
62
parent::setDefaults();
63
64
$this->defaults[
'rows'
] =
null
;
65
$this->defaults[
'cols'
] =
null
;
66
$this->defaults[
'autogrow'
] =
false
;
67
}
68
74
public
function
__toString
(): string
75
{
76
$label
= $this->htmlLabel();
77
$marker
= $this->
htmlMarker
();
78
$inputAttributes = $this->
htmlInputAttributes
();
79
$value
= $this->
htmlValue
();
80
$rows
= $this->
htmlRows
();
81
$cols
= $this->
htmlCols
();
82
$wrapperAttributes = $this->
htmlWrapperAttributes
();
83
$errorMessage
= $this->
htmlErrorMessage
();
84
$helpMessage
= $this->
htmlHelpMessage
();
85
86
return
"<p {$wrapperAttributes}>"
.
87
"<label>"
.
88
"<span class=\"depage-label\">{$label}{$marker}</span>"
.
89
"<textarea name=\"{$this->name}\"{$inputAttributes}{$rows}{$cols}>{$value}</textarea>"
.
90
"</label>"
.
91
$errorMessage
.
92
$helpMessage
.
93
"</p>\n"
;
94
}
95
99
protected
function
htmlDataAttributes
(): string
100
{
101
$options = [];
102
$options[
'autogrow'
] =
$this->autogrow
;
103
104
$this->dataAttr[
'textarea-options'
] = json_encode($options);
105
106
return
parent::htmlDataAttributes();
107
}
108
114
protected
function
htmlRows
(): string
115
{
116
return
($this->rows ===
null
) ?
""
:
" rows=\""
. $this->
htmlEscape
($this->rows) .
"\""
;
117
}
118
123
protected
function
htmlCols
(): string
124
{
125
return
($this->cols ===
null
) ?
""
:
" cols=\""
. $this->
htmlEscape
($this->cols) .
"\""
;
126
}
127
}
128
129
/* vim:set ft=php sw=4 sts=4 fdm=marker et : */
Depage\HtmlForm\Abstracts\Element\htmlEscape
htmlEscape(array|string $options=[])
Escapes HTML in strings and arrays of strings.
Definition
Element.php:263
Depage\HtmlForm\Abstracts\Input\$value
$value
Input elements's value.
Definition
Input.php:124
Depage\HtmlForm\Abstracts\Input\$label
$label
Input element - HTML label.
Definition
Input.php:37
Depage\HtmlForm\Abstracts\Input\$errorMessage
$errorMessage
Message that gets displayed in case of invalid input.
Definition
Input.php:218
Depage\HtmlForm\Abstracts\Input\htmlHelpMessage
htmlHelpMessage()
Returns HTML-rendered helpMessage.
Definition
Input.php:685
Depage\HtmlForm\Abstracts\Input\htmlWrapperAttributes
htmlWrapperAttributes()
Returns string of HTML attributes for element wrapper paragraph.
Definition
Input.php:636
Depage\HtmlForm\Abstracts\Input\htmlMarker
htmlMarker()
Returns elements' required-indicator.
Definition
Input.php:566
Depage\HtmlForm\Abstracts\Input\$helpMessage
$helpMessage
Extra help message.
Definition
Input.php:230
Depage\HtmlForm\Abstracts\Input\htmlValue
htmlValue()
Returns HTML-rendered element value.
Definition
Input.php:656
Depage\HtmlForm\Abstracts\Input\$marker
$marker
Input element - HTML marker text that marks required fields.
Definition
Input.php:92
Depage\HtmlForm\Abstracts\Input\htmlErrorMessage
htmlErrorMessage()
Returns HTML-rendered error message.
Definition
Input.php:666
Depage\HtmlForm\Elements\Text
HTML text input type.
Definition
Text.php:40
Depage\HtmlForm\Elements\Text\htmlInputAttributes
htmlInputAttributes()
renders text element specific HTML attributes
Definition
Text.php:160
Depage\HtmlForm\Elements\Textarea
HTML textarea element.
Definition
Textarea.php:36
Depage\HtmlForm\Elements\Textarea\htmlCols
htmlCols()
Renders HTML cols attribute.
Definition
Textarea.php:123
Depage\HtmlForm\Elements\Textarea\$autogrow
$autogrow
wether to autogrow textarea or not
Definition
Textarea.php:50
Depage\HtmlForm\Elements\Textarea\htmlDataAttributes
htmlDataAttributes()
Returns dataAttr escaped as attribute string.
Definition
Textarea.php:99
Depage\HtmlForm\Elements\Textarea\htmlRows
htmlRows()
Renders HTML rows attribute.
Definition
Textarea.php:114
Depage\HtmlForm\Elements\Textarea\__toString
__toString()
Renders element to HTML.
Definition
Textarea.php:74
Depage\HtmlForm\Elements\Textarea\$cols
$cols
HTML cols attribute.
Definition
Textarea.php:45
Depage\HtmlForm\Elements\Textarea\setDefaults
setDefaults()
collects initial values across subclasses
Definition
Textarea.php:60
Depage\HtmlForm\Elements\Textarea\$rows
$rows
HTML rows attribute.
Definition
Textarea.php:40
Elements
Textarea.php
Generated on
for depage-forms by
doxygen
1.18.0
For an overview of all docs, go to
docs.depage.net