Skip to content

Commit a4eca70

Browse files
BastianLedererIcinganilmerg
authored andcommitted
RotationConfigForm: Fix handoff interval 0
To prevent errors when calculating the first handoff, add a missing `GreaterThanValidator` to the multi day interval field and let the first-handoff description's deferred text handlers return an empty string while the form is invalid.
1 parent af39a5d commit a4eca70

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

application/forms/RotationConfigForm.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,8 @@ protected function assembleMultiDayOptions(FieldsetElement $options): DateTime
955955
'min' => 1,
956956
'value' => 1,
957957
'label' => $this->translate('Handoff every'),
958-
'description' => $this->translate('Have multiple rotation members take turns after this interval.')
958+
'description' => $this->translate('Have multiple rotation members take turns after this interval.'),
959+
'validators' => [new GreaterThanValidator()]
959960
]);
960961
$interval = $options->getElement('interval');
961962
$interval->getDecorators()
@@ -1240,6 +1241,10 @@ function ($value, $validator) use ($earliestHandoff, $firstHandoff, $latestHando
12401241
'p',
12411242
Attributes::create(['id' => 'first-handoff-description']),
12421243
DeferredText::create(function () {
1244+
if (! $this->isValid()) {
1245+
return '';
1246+
}
1247+
12431248
$ruleGenerator = $this->yieldRecurrenceRules(1);
12441249
if (! $ruleGenerator->valid()) {
12451250
return $this->translate('This rotation can no longer happen');
@@ -1262,6 +1267,10 @@ function ($value, $validator) use ($earliestHandoff, $firstHandoff, $latestHando
12621267
}),
12631268
new HtmlElement('br'),
12641269
$this->displayTimezone !== $this->scheduleTimezone ? DeferredText::create(function () {
1270+
if (! $this->isValid()) {
1271+
return '';
1272+
}
1273+
12651274
$ruleGenerator = $this->yieldRecurrenceRules(1);
12661275
if (! $ruleGenerator->valid()) {
12671276
return '';

0 commit comments

Comments
 (0)