depage-forms
v2.0.0
html forms made easy
Toggle main menu visibility
Loading...
Searching...
No Matches
Button.php
Go to the documentation of this file.
1
<?php
2
10
11
namespace
Depage\HtmlForm\Elements;
12
13
use Depage\HtmlForm\Abstracts;
14
39
class
Button
extends
\Depage\HtmlForm\Abstracts\Input
40
{
41
protected
$defaultValue
=
""
;
42
52
protected
function
setDefaults
(): void
53
{
54
parent::setDefaults();
55
56
$this->defaults[
'defaultValue'
] =
false
;
57
}
58
68
public
function
setValue
(mixed $newValue): bool
69
{
70
if
(is_bool($newValue)) {
71
$this->value = $newValue;
72
} elseif ($newValue ===
"true"
) {
73
$this->value =
true
;
74
}
else
{
75
$this->value =
false
;
76
}
77
78
return
$this->value
;
79
}
80
86
public
function
__toString
(): string
87
{
88
$value
=
"true"
;
89
$type
=
"submit"
;
90
$inputAttributes = $this->
htmlInputAttributes
();
91
$marker
= $this->
htmlMarker
();
92
$label
= $this->htmlLabel();
93
$wrapperAttributes = $this->
htmlWrapperAttributes
();
94
$errorMessage
= $this->
htmlErrorMessage
();
95
$helpMessage
= $this->
htmlHelpMessage
();
96
97
return
"<p {$wrapperAttributes}>"
.
98
"<button name=\"{$this->name}\" type=\"submit\"{$inputAttributes} value=\"{$value}\">{$label}</button>"
.
99
$errorMessage
.
100
$helpMessage
.
101
"</p>\n"
;
102
}
103
}
104
105
/* vim:set ft=php sw=4 sts=4 fdm=marker et : */
Depage\HtmlForm\Abstracts\Input
input element base class
Definition
Input.php:22
Depage\HtmlForm\Abstracts\Input\htmlInputAttributes
htmlInputAttributes()
Returns string of HTML attributes for input element.
Definition
Input.php:576
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\$type
$type
Input element type - HTML input type attribute.
Definition
Input.php:26
Depage\HtmlForm\Abstracts\Input\$helpMessage
$helpMessage
Extra help message.
Definition
Input.php:230
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\Button
HTML text input type.
Definition
Button.php:40
Depage\HtmlForm\Elements\Button\setValue
setValue(mixed $newValue)
set the boolean element value
Definition
Button.php:68
Depage\HtmlForm\Elements\Button\__toString
__toString()
Renders element to HTML.
Definition
Button.php:86
Depage\HtmlForm\Elements\Button\$defaultValue
$defaultValue
Definition
Button.php:41
Depage\HtmlForm\Elements\Button\setDefaults
setDefaults()
collects initial values across subclasses
Definition
Button.php:52
Elements
Button.php
Generated on
for depage-forms by
doxygen
1.18.0
For an overview of all docs, go to
docs.depage.net