1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
<?php
/* Icinga Web 2 | (c) 2018 Icinga Development Team | GPLv2+ */
namespace Icinga\Forms;
use Icinga\Application\Hook\ConfigFormEventsHook;
use Icinga\Web\Form;
class ActionForm extends Form
{
/**
* The icon shown on the button
*
* @var string
*/
protected $icon = 'arrows-cw';
/**
* Set the icon to show on the button
*
* @param string $name
*
* @return $this
*/
public function setIcon($name)
{
$this->icon = (string) $name;
return $this;
}
public function init()
{
$this->setAttrib('class', 'inline');
$this->setUidDisabled(true);
$this->setDecorators(['FormElements', 'Form']);
}
public function createElements(array $formData)
{
$this->addElement(
'hidden',
'identifier',
[
'required' => true,
'decorators' => ['ViewHelper']
]
);
$this->addElement(
'button',
'btn_submit',
[
'escape' => false,
'type' => 'submit',
'class' => 'link-button spinner',
'value' => 'btn_submit',
'decorators' => ['ViewHelper'],
'label' => $this->getView()->icon($this->icon),
'title' => $this->getDescription()
]
);
}
public function isValid($formData)
{
$valid = parent::isValid($formData);
if ($valid) {
$valid = ConfigFormEventsHook::runIsValid($this);
}
return $valid;
}
public function onSuccess()
{
ConfigFormEventsHook::runOnSuccess($this);
}
}
|