|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Alfs18\User\HTMLForm; |
|
4
|
|
|
|
|
5
|
|
|
use Anax\HTMLForm\FormModel; |
|
6
|
|
|
use Psr\Container\ContainerInterface; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Example of FormModel implementation. |
|
10
|
|
|
*/ |
|
11
|
|
|
class FormModelCheckboxMultiple extends FormModel |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* Constructor injects with DI container. |
|
15
|
|
|
* |
|
16
|
|
|
* @param Anax\DI\DIInterface $di a service container |
|
|
|
|
|
|
17
|
|
|
*/ |
|
18
|
|
|
public function __construct(ContainerInterface $di, $tags) |
|
19
|
|
|
{ |
|
20
|
|
|
parent::__construct($di); |
|
21
|
|
|
$this->form->create( |
|
22
|
|
|
[ |
|
23
|
|
|
"id" => __CLASS__, |
|
24
|
|
|
"legend" => "Taggar" |
|
25
|
|
|
], |
|
26
|
|
|
[ |
|
27
|
|
|
"items" => [ |
|
28
|
|
|
"type" => "checkbox-multiple", |
|
29
|
|
|
"values" => $tags, |
|
30
|
|
|
// "values" => ["tomato", "potato", "apple", "pear", "banana"], |
|
31
|
|
|
// "checked" => ["potato", "pear"], |
|
32
|
|
|
], |
|
33
|
|
|
"submit" => [ |
|
34
|
|
|
"type" => "submit", |
|
35
|
|
|
"callback" => [$this, "callbackSubmit"], |
|
36
|
|
|
], |
|
37
|
|
|
] |
|
38
|
|
|
); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Callback for submit-button which should return true if it could |
|
45
|
|
|
* carry out its work and false if something failed. |
|
46
|
|
|
* |
|
47
|
|
|
* @return boolean true if okey, false if something went wrong. |
|
48
|
|
|
*/ |
|
49
|
|
|
public function callbackSubmit() |
|
50
|
|
|
{ |
|
51
|
|
|
// Get the selected items as an array |
|
52
|
|
|
$items = $this->form->value("items"); |
|
53
|
|
|
|
|
54
|
|
|
// Print output for sake of this example |
|
55
|
|
|
$this->form->addOutput( |
|
56
|
|
|
"<p>Selected items are: '" |
|
57
|
|
|
. implode(", ", $items) |
|
58
|
|
|
. "'." |
|
59
|
|
|
); |
|
60
|
|
|
|
|
61
|
|
|
// Remember values during resubmit, for sake of the example |
|
62
|
|
|
$this->form->rememberValues(); |
|
63
|
|
|
|
|
64
|
|
|
return $items; |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
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