Skip to content

Commit b7c6ae7

Browse files
author
Timm Ortloff
committed
ReportForm: Pass elements into setAddElement and setRemoveElement
1 parent 0c907ca commit b7c6ae7

1 file changed

Lines changed: 20 additions & 13 deletions

File tree

library/Reporting/Web/Forms/ReportForm.php

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

89+
$addElement = $this->createElement('select', 'reportlet', [
90+
'required' => false,
91+
'label' => 'Reportlet',
92+
'options' => [null => 'Please choose'] + $this->listReports(),
93+
'class' => 'autosubmit'
94+
]);
95+
$this->registerElement($addElement);
96+
$this->decorate($addElement);
97+
98+
$removeElement = $this->createElement('submitButton', 'remove_reportlet', [
99+
'label' => new Icon('trash'),
100+
'class' => 'btn-remove-reportlet',
101+
'formnovalidate' => true,
102+
'title' => 'Remove Reportlet'
103+
]);
104+
$this->registerElement($removeElement);
105+
$this->decorate($removeElement);
89106

90107
$collection
91-
->setAddElement('select', 'reportlet', [
92-
'required' => false,
93-
'label' => 'Reportlet',
94-
'options' => [null => 'Please choose'] + $this->listReports(),
95-
'class' => 'autosubmit'
96-
])
97-
->setRemoveElement('submitButton', 'remove_reportlet', [
98-
'label' => new Icon('trash'),
99-
'class' => 'btn-remove-reportlet',
100-
'formnovalidate' => true,
101-
'title' => 'Remove Reportlet'
102-
]);
108+
->setAddElement($addElement)
109+
->setRemoveElement($removeElement);
103110

104-
$collection->onAssembleGroup(function (/** @var Fieldset $group */ $group, $addElement, $removeElement) {
111+
$collection->onAssembleGroup(function ($group, $addElement, $removeElement) {
105112
$group->setDefaultElementDecorator(new IcingaFormDecorator());
106113

107114
$this->decorate($addElement);

0 commit comments

Comments
 (0)