Skip to content

Commit 4ba49e7

Browse files
raviks789nilmerg
authored andcommitted
EntryForm: Validate entry duration against its frequency
Entry duration should be shorter than their frequency for recurrent entries.
1 parent 3f69cf5 commit 4ba49e7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

application/forms/EntryForm.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,20 @@ protected function assemble()
180180
);
181181

182182
return false;
183+
} elseif ($this->getValue('frequency') !== self::NO_REPEAT) {
184+
/** @var Frequency $frequency */
185+
$frequency = $this->getValue();
186+
$next = $frequency->getNextDue($value);
187+
188+
if ($endTime > $next) {
189+
$validator->addMessage(
190+
$this->translate(
191+
'The entry should end before the next occurrence.'
192+
)
193+
);
194+
195+
return false;
196+
}
183197
}
184198

185199
return true;

0 commit comments

Comments
 (0)