Skip to content

Commit

Permalink
ReportForm: Pass elements into setAddElement and setRemoveElement
Browse files Browse the repository at this point in the history
  • Loading branch information
Timm Ortloff committed Feb 2, 2023
1 parent 5450b92 commit 4748798
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions library/Reporting/Web/Forms/ReportForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,29 @@ protected function assemble()
$collection = new Collection('reportlet');
$collection->setLabel('Reportlets');

$addElement = $this->createElement('select', 'reportlet', [
'required' => false,
'label' => 'Reportlet',
'options' => [null => 'Please choose'] + $this->listReports(),
'class' => 'autosubmit'
]);
$this->registerElement($addElement);
$this->decorate($addElement);

$removeElement = $this->createElement('submitButton', 'remove_reportlet', [
'label' => new Icon('trash'),
'class' => 'btn-remove-reportlet',
'formnovalidate' => true,
'title' => 'Remove Reportlet'
]);
$this->registerElement($removeElement);
$this->decorate($removeElement);

$collection
->setAddElement('select', 'reportlet', [
'required' => false,
'label' => 'Reportlet',
'options' => [null => 'Please choose'] + $this->listReports(),
'class' => 'autosubmit'
])
->setRemoveElement('submitButton', 'remove_reportlet', [
'label' => new Icon('trash'),
'class' => 'btn-remove-reportlet',
'formnovalidate' => true,
'title' => 'Remove Reportlet'
]);
->setAddElement($addElement)
->setRemoveElement($removeElement);

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

$this->decorate($addElement);
Expand Down

0 comments on commit 4748798

Please sign in to comment.