This class seems to be duplicated in your project.
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.
Loading history...
11
{
12
/**
13
* Constructor injects with DI container.
14
*
15
* @param Anax\DI\DIInterface $di a service container
16
*/
17
public function __construct(DIInterface $di)
18
{
19
parent::__construct($di);
20
$this->form->create(
21
[
22
"id" => __CLASS__,
23
"legend" => "Legend",
24
],
25
[
26
"text" => [
27
"type" =>"text",
28
"label" => "Text, not empty (as input type=text)",
29
"validation" => ["not_empty"],
30
],
31
32
"submit" => [
33
"type" => "submit",
34
"value" => "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
$this->form->addOutput("Validation passes.");
52
53
// Remember values during resubmit, for sake of the example
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.