Skip to content

Commit 4748798

Browse files
author
Timm Ortloff
committed
ReportForm: Pass elements into setAddElement and setRemoveElement
1 parent 5450b92 commit 4748798

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

library/Reporting/Web/Forms/ReportForm.php

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,22 +96,29 @@ protected function assemble()
9696
$collection = new Collection('reportlet');
9797
$collection->setLabel('Reportlets');
9898

99+
$addElement = $this->createElement('select', 'reportlet', [
100+
'required' => false,
101+
'label' => 'Reportlet',
102+
'options' => [null => 'Please choose'] + $this->listReports(),
103+
'class' => 'autosubmit'
104+
]);
105+
$this->registerElement($addElement);
106+
$this->decorate($addElement);
107+
108+
$removeElement = $this->createElement('submitButton', 'remove_reportlet', [
109+
'label' => new Icon('trash'),
110+
'class' => 'btn-remove-reportlet',
111+
'formnovalidate' => true,
112+
'title' => 'Remove Reportlet'
113+
]);
114+
$this->registerElement($removeElement);
115+
$this->decorate($removeElement);
99116

100117
$collection
101-
->setAddElement('select', 'reportlet', [
102-
'required' => false,
103-
'label' => 'Reportlet',
104-
'options' => [null => 'Please choose'] + $this->listReports(),
105-
'class' => 'autosubmit'
106-
])
107-
->setRemoveElement('submitButton', 'remove_reportlet', [
108-
'label' => new Icon('trash'),
109-
'class' => 'btn-remove-reportlet',
110-
'formnovalidate' => true,
111-
'title' => 'Remove Reportlet'
112-
]);
118+
->setAddElement($addElement)
119+
->setRemoveElement($removeElement);
113120

114-
$collection->onAssembleGroup(function (/** @var Fieldset $group */ $group, $addElement, $removeElement) {
121+
$collection->onAssembleGroup(function ($group, $addElement, $removeElement) {
115122
$group->setDefaultElementDecorator(new IcingaFormDecorator());
116123

117124
$this->decorate($addElement);

0 commit comments

Comments
 (0)