prepare break time field (#5366)

This commit is contained in:
Kevin Papst
2025-02-20 14:46:20 +01:00
committed by GitHub
parent b341358d0a
commit 8a8d0503f7
2 changed files with 8 additions and 1 deletions

View File

@@ -310,6 +310,10 @@ class TimesheetEditForm extends AbstractType
$builder->add('duration', DurationType::class, $durationOptions);
if ($this->systemConfiguration->isBreakTimeEnabled()) {
$builder->add('break', DurationType::class, ['label' => 'break', 'required' => false]);
}
$builder->addEventListener(
FormEvents::POST_SET_DATA,
function (FormEvent $event) {
@@ -338,7 +342,7 @@ class TimesheetEditForm extends AbstractType
$duration = $timesheet->getDuration() ?? 0;
// only apply the duration, if the end is not yet set
// only apply the duration, if the end is not yet set.
// without that check, the end would be overwritten and the real end time would be lost
if (($forceApply && $duration > 0) || ($duration > 0 && $timesheet->isRunning())) {
$end = clone $timesheet->getBegin();