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 Dec 22, 2022
1 parent 70bfd3c commit f5c2ecc
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 @@ -72,22 +72,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 f5c2ecc

Please sign in to comment.