mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
household address: add max date for changing the validFrom date
This commit is contained in:
parent
017b7bca87
commit
6a4edd000f
@ -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
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -13,10 +13,16 @@
|
||||
|
||||
|
||||
<div>
|
||||
{% if minValidFrom is not null %}
|
||||
{{ form_row(form.validFrom, {'attr': {'min': minValidFrom|date('Y-m-d') }}) }}
|
||||
{% if minValidFrom is not null and maxValidFrom is not null %}
|
||||
{{ form_row(form.validFrom, {'attr': {'min': minValidFrom|date('Y-m-d'), 'max': maxValidFrom|date('Y-m-d') }}) }}
|
||||
{% else %}
|
||||
{{ form_row(form.validFrom) }}
|
||||
{% if minValidFrom is not null %}
|
||||
{{ form_row(form.validFrom, {'attr': {'min': minValidFrom|date('Y-m-d')}}) }}
|
||||
{% elseif maxValidFrom is not null %}
|
||||
{{ form_row(form.validFrom, {'attr': {'max': maxValidFrom|date('Y-m-d')}}) }}
|
||||
{% else %}
|
||||
{{ form_row(form.validFrom) }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div hidden>
|
||||
|
Loading…
x
Reference in New Issue
Block a user