Skip to content

Commit 04af9ed

Browse files
committed
RotationConfigForm: Use new decorators
1 parent 626d0c6 commit 04af9ed

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

application/forms/RotationConfigForm.php

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use ipl\Validator\GreaterThanValidator;
3131
use ipl\Web\Common\CsrfCounterMeasure;
3232
use ipl\Web\Compat\CompatForm;
33+
use ipl\Web\FormDecorator\IcingaFormDecorator;
3334
use ipl\Web\FormElement\TermInput;
3435
use ipl\Web\Url;
3536
use LogicException;
@@ -190,6 +191,8 @@ public function __construct(int $scheduleId, Connection $db)
190191
{
191192
$this->db = $db;
192193
$this->scheduleId = $scheduleId;
194+
195+
$this->applyDefaultElementDecorators();
193196
}
194197

195198
/**
@@ -1058,8 +1061,9 @@ protected function assemble()
10581061
]
10591062
]);
10601063

1061-
$options = new FieldsetElement('options');
1062-
$this->addElement($options);
1064+
$this->addElement('fieldset', 'options');
1065+
/** @var FieldsetElement $options */
1066+
$options = $this->getElement('options');
10631067

10641068
if ($mode === '24-7') {
10651069
$firstHandoff = $this->assembleTwentyFourSevenOptions($options);
@@ -1193,20 +1197,24 @@ function ($value, $validator) use ($earliestHandoff, $firstHandoff, $latestHando
11931197
}
11941198
};
11951199

1196-
$this->addElement(
1197-
(new TermInput('members'))
1198-
->setIgnored()
1199-
->setRequired()
1200-
->setOrdered()
1201-
->setReadOnly()
1202-
->setVerticalTermDirection()
1203-
->setLabel($this->translate('Members'))
1204-
->setSuggestionUrl($this->suggestionUrl->with(['showCompact' => true, '_disableLayout' => 1]))
1205-
->on(TermInput::ON_ENRICH, $termValidator)
1206-
->on(TermInput::ON_ADD, $termValidator)
1207-
->on(TermInput::ON_SAVE, $termValidator)
1208-
->on(TermInput::ON_PASTE, $termValidator)
1209-
);
1200+
$members = (new TermInput('members'))
1201+
->setIgnored()
1202+
->setRequired()
1203+
->setOrdered()
1204+
->setReadOnly()
1205+
->setVerticalTermDirection()
1206+
->setLabel($this->translate('Members'))
1207+
->setSuggestionUrl($this->suggestionUrl->with(['showCompact' => true, '_disableLayout' => 1]))
1208+
->on(TermInput::ON_ENRICH, $termValidator)
1209+
->on(TermInput::ON_ADD, $termValidator)
1210+
->on(TermInput::ON_SAVE, $termValidator)
1211+
->on(TermInput::ON_PASTE, $termValidator);
1212+
$this->addElement($members);
1213+
1214+
// TODO: TermInput is not compatible with the new decorators yet: https://github.com/Icinga/ipl-web/pull/317
1215+
$legacyDecorator = new IcingaFormDecorator();
1216+
$members->setDefaultElementDecorator($legacyDecorator);
1217+
$legacyDecorator->decorate($members);
12101218

12111219
$this->addElement('submit', 'submit', [
12121220
'label' => $this->getSubmitLabel()

0 commit comments

Comments
 (0)