1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Anax\HTMLForm; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Example of FormModel implementation. |
7
|
|
|
*/ |
8
|
|
|
class FormModelElementsHTML5 extends FormModel |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Constructor |
12
|
|
|
* |
13
|
|
|
*/ |
14
|
|
|
public function __construct() |
15
|
|
|
{ |
16
|
|
|
parent::__construct( |
17
|
|
|
[ |
18
|
|
|
"legend" => "Legend" |
19
|
|
|
], |
20
|
|
|
[ |
21
|
|
|
"color" => [ |
22
|
|
|
"type" => "color", |
23
|
|
|
"description" => "Here you can place a description.", |
24
|
|
|
"placeholder" => "Here is a placeholder", |
25
|
|
|
], |
26
|
|
|
|
27
|
|
|
"date" => [ |
28
|
|
|
"type" => "date", |
29
|
|
|
"description" => "Here you can place a description.", |
30
|
|
|
"placeholder" => "Here is a placeholder", |
31
|
|
|
], |
32
|
|
|
|
33
|
|
|
"datetime" => [ |
34
|
|
|
"type" => "datetime", |
35
|
|
|
"description" => "Here you can place a description.", |
36
|
|
|
"placeholder" => "Here is a placeholder", |
37
|
|
|
], |
38
|
|
|
|
39
|
|
|
"datetime-local" => [ |
40
|
|
|
"type" => "datetime-local", |
41
|
|
|
"description" => "Here you can place a description.", |
42
|
|
|
"placeholder" => "Here is a placeholder", |
43
|
|
|
], |
44
|
|
|
|
45
|
|
|
"time" => [ |
46
|
|
|
"type" => "time", |
47
|
|
|
"description" => "Here you can place a description.", |
48
|
|
|
"placeholder" => "Here is a placeholder", |
49
|
|
|
], |
50
|
|
|
|
51
|
|
|
"week" => [ |
52
|
|
|
"type" => "week", |
53
|
|
|
"description" => "Here you can place a description.", |
54
|
|
|
"placeholder" => "Here is a placeholder", |
55
|
|
|
], |
56
|
|
|
|
57
|
|
|
"month" => [ |
58
|
|
|
"type" => "month", |
59
|
|
|
"description" => "Here you can place a description.", |
60
|
|
|
"placeholder" => "Here is a placeholder", |
61
|
|
|
], |
62
|
|
|
|
63
|
|
|
"number" => [ |
64
|
|
|
"type" => "number", |
65
|
|
|
"description" => "Here you can place a description.", |
66
|
|
|
"placeholder" => "Here is a placeholder", |
67
|
|
|
], |
68
|
|
|
|
69
|
|
|
"range" => [ |
70
|
|
|
"type" => "range", |
71
|
|
|
"description" => "Here you can place a description.", |
72
|
|
|
"placeholder" => "Here is a placeholder", |
73
|
|
|
"value" => 42, |
74
|
|
|
"min" => 0, |
75
|
|
|
"max" => 100, |
76
|
|
|
"step" => 2, |
77
|
|
|
], |
78
|
|
|
|
79
|
|
|
"search" => [ |
80
|
|
|
"type" => "search", |
81
|
|
|
"label" => "Search:", |
82
|
|
|
"description" => "Here you can place a description.", |
83
|
|
|
"placeholder" => "Here is a placeholder", |
84
|
|
|
], |
85
|
|
|
|
86
|
|
|
"tel" => [ |
87
|
|
|
"type" => "tel", |
88
|
|
|
"description" => "Here you can place a description.", |
89
|
|
|
"placeholder" => "Here is a placeholder", |
90
|
|
|
], |
91
|
|
|
|
92
|
|
|
"email" => [ |
93
|
|
|
"type" => "email", |
94
|
|
|
"description" => "Here you can place a description.", |
95
|
|
|
"placeholder" => "Here is a placeholder", |
96
|
|
|
], |
97
|
|
|
|
98
|
|
|
"url" => [ |
99
|
|
|
"type" => "url", |
100
|
|
|
"description" => "Here you can place a description.", |
101
|
|
|
"placeholder" => "Here is a placeholder", |
102
|
|
|
], |
103
|
|
|
|
104
|
|
|
"file-multiple" => [ |
105
|
|
|
"type" => "file-multiple", |
106
|
|
|
"description" => "Here you can place a description.", |
107
|
|
|
], |
108
|
|
|
|
109
|
|
|
"reset" => [ |
110
|
|
|
"type" => "reset", |
111
|
|
|
], |
112
|
|
|
|
113
|
|
|
"submit" => [ |
114
|
|
|
"type" => "submit", |
115
|
|
|
"value" => "Submit", |
116
|
|
|
"callback" => [$this, "callbackSubmit"] |
117
|
|
|
], |
118
|
|
|
] |
119
|
|
|
); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
|
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Callback for submit-button. |
126
|
|
|
* |
127
|
|
|
*/ |
128
|
|
View Code Duplication |
public function callbackSubmit() |
|
|
|
|
129
|
|
|
{ |
130
|
|
|
$this->AddOutput("<p>#callbackSubmit()</p>"); |
131
|
|
|
$this->AddOutput("<pre>" . print_r($_POST, 1) . "</pre>"); |
132
|
|
|
$this->saveInSession = true; |
|
|
|
|
133
|
|
|
|
134
|
|
|
return true; |
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.