1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Anax\HTMLForm; |
4
|
|
|
|
5
|
|
|
use Psr\Container\ContainerInterface; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Example of FormModel implementation. |
9
|
|
|
*/ |
10
|
|
|
class FormModelElementsHTML5 extends FormModel |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Constructor injects with DI container. |
14
|
|
|
* |
15
|
|
|
* @param Anax\DI\DIInterface $di a service container |
|
|
|
|
16
|
|
|
*/ |
17
|
|
|
public function __construct(ContainerInterface $di) |
18
|
|
|
{ |
19
|
|
|
parent::__construct($di); |
20
|
|
|
$this->form->create( |
21
|
|
|
[ |
22
|
|
|
"id" => __CLASS__, |
23
|
|
|
"legend" => "Legend", |
24
|
|
|
//"wrapper-element" => "div", |
25
|
|
|
], |
26
|
|
|
[ |
27
|
|
|
"color" => [ |
28
|
|
|
"type" => "color", |
29
|
|
|
"description" => "Here you can place a description.", |
30
|
|
|
"placeholder" => "Here is a placeholder", |
31
|
|
|
], |
32
|
|
|
|
33
|
|
|
"date" => [ |
34
|
|
|
"type" => "date", |
35
|
|
|
"description" => "Here you can place a description.", |
36
|
|
|
"placeholder" => "Here is a placeholder", |
37
|
|
|
], |
38
|
|
|
|
39
|
|
|
"datetime" => [ |
40
|
|
|
"type" => "datetime", |
41
|
|
|
"description" => "Here you can place a description.", |
42
|
|
|
"placeholder" => "Here is a placeholder", |
43
|
|
|
], |
44
|
|
|
|
45
|
|
|
"datetime-local" => [ |
46
|
|
|
"type" => "datetime-local", |
47
|
|
|
"description" => "Here you can place a description.", |
48
|
|
|
"placeholder" => "Here is a placeholder", |
49
|
|
|
], |
50
|
|
|
|
51
|
|
|
"time" => [ |
52
|
|
|
"type" => "time", |
53
|
|
|
"description" => "Here you can place a description.", |
54
|
|
|
"placeholder" => "Here is a placeholder", |
55
|
|
|
], |
56
|
|
|
|
57
|
|
|
"week" => [ |
58
|
|
|
"type" => "week", |
59
|
|
|
"description" => "Here you can place a description.", |
60
|
|
|
"placeholder" => "Here is a placeholder", |
61
|
|
|
], |
62
|
|
|
|
63
|
|
|
"month" => [ |
64
|
|
|
"type" => "month", |
65
|
|
|
"description" => "Here you can place a description.", |
66
|
|
|
"placeholder" => "Here is a placeholder", |
67
|
|
|
], |
68
|
|
|
|
69
|
|
|
"number" => [ |
70
|
|
|
"type" => "number", |
71
|
|
|
"description" => "Here you can place a description.", |
72
|
|
|
"placeholder" => "Here is a placeholder", |
73
|
|
|
], |
74
|
|
|
|
75
|
|
|
"range" => [ |
76
|
|
|
"type" => "range", |
77
|
|
|
"description" => "Here you can place a description.", |
78
|
|
|
"placeholder" => "Here is a placeholder", |
79
|
|
|
"value" => 42, |
80
|
|
|
"min" => 0, |
81
|
|
|
"max" => 100, |
82
|
|
|
"step" => 2, |
83
|
|
|
], |
84
|
|
|
|
85
|
|
|
"search" => [ |
86
|
|
|
"type" => "search", |
87
|
|
|
"label" => "Search:", |
88
|
|
|
"description" => "Here you can place a description.", |
89
|
|
|
"placeholder" => "Here is a placeholder", |
90
|
|
|
], |
91
|
|
|
|
92
|
|
|
"tel" => [ |
93
|
|
|
"type" => "tel", |
94
|
|
|
"description" => "Here you can place a description.", |
95
|
|
|
"placeholder" => "Here is a placeholder", |
96
|
|
|
], |
97
|
|
|
|
98
|
|
|
"email" => [ |
99
|
|
|
"type" => "email", |
100
|
|
|
"description" => "Here you can place a description.", |
101
|
|
|
"placeholder" => "Here is a placeholder", |
102
|
|
|
], |
103
|
|
|
|
104
|
|
|
"url" => [ |
105
|
|
|
"type" => "url", |
106
|
|
|
"description" => "Here you can place a description.", |
107
|
|
|
"placeholder" => "Here is a placeholder", |
108
|
|
|
], |
109
|
|
|
|
110
|
|
|
"file-multiple" => [ |
111
|
|
|
"type" => "file-multiple", |
112
|
|
|
"description" => "Here you can place a description.", |
113
|
|
|
], |
114
|
|
|
|
115
|
|
|
"reset" => [ |
116
|
|
|
"type" => "reset", |
117
|
|
|
], |
118
|
|
|
|
119
|
|
|
"submit" => [ |
120
|
|
|
"type" => "submit", |
121
|
|
|
"value" => "Submit", |
122
|
|
|
"callback" => [$this, "callbackSubmit"] |
123
|
|
|
], |
124
|
|
|
] |
125
|
|
|
); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
|
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Callback for submit-button which should return true if it could |
132
|
|
|
* carry out its work and false if something failed. |
133
|
|
|
* |
134
|
|
|
* @return boolean true if okey, false if something went wrong. |
135
|
|
|
*/ |
136
|
|
|
public function callbackSubmit() |
137
|
|
|
{ |
138
|
|
|
// Read all values for the sake of this example |
139
|
|
|
$elements = [ |
140
|
|
|
"color", "date", "datetime", "datetime-local", "time", |
141
|
|
|
"week", "month", "number", "range", "search", "tel", |
142
|
|
|
"email", "url", "file-multiple", |
143
|
|
|
]; |
144
|
|
|
foreach ($elements as $name) { |
145
|
|
|
$this->form->addOutput( |
146
|
|
|
"$name has value: " |
147
|
|
|
. $this->form->value($name) |
148
|
|
|
. "</br>" |
149
|
|
|
); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
// Remember values during resubmit, for sake of the example |
153
|
|
|
$this->form->rememberValues(); |
154
|
|
|
|
155
|
|
|
return true; |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths