household address: add max date for changing the validFrom date

This commit is contained in:
nobohan
2022-04-06 15:31:17 +02:00
parent 017b7bca87
commit 6a4edd000f
2 changed files with 18 additions and 4 deletions

View File

@@ -172,6 +172,13 @@ class HouseholdController extends AbstractController
$minValidFrom = null;
}
if (count($addresses) > 1 && count($addresses) > $currentValueIndex + 1) {
$nextAddress = $addresses[$currentValueIndex + 1];
$maxValidFrom = $nextAddress->getValidFrom();
} else {
$maxValidFrom = null;
}
if ($form->isSubmitted() && $form->isValid()) {
$this->getDoctrine()->getManager()->persist($address);
$this->getDoctrine()->getManager()->flush();
@@ -186,7 +193,8 @@ class HouseholdController extends AbstractController
'household' => $household,
'address' => $address,
'form' => $form->createView(),
'minValidFrom' => $minValidFrom
'minValidFrom' => $minValidFrom,
'maxValidFrom' => $maxValidFrom
]
);
}