From beaccd93e0de0ed5254619f724f144e9c205ac23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Tue, 11 Nov 2025 15:39:56 +0100 Subject: [PATCH] fix: show rental insurance field only when applicable --- src/Form/ParticipantType.php | 14 ++++++++------ templates/booking/edit.html.twig | 8 +++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Form/ParticipantType.php b/src/Form/ParticipantType.php index 93b3cbb..56fadd5 100644 --- a/src/Form/ParticipantType.php +++ b/src/Form/ParticipantType.php @@ -256,12 +256,14 @@ class ParticipantType extends AbstractType 'choices' => $options['selectable_parking'], ]); - // Rental Insurance - single checkbox (always add, JS will show/hide when rentals selected) - $form->add('rentalInsurance', ChoiceType::class, [ - ...$commonChoiceFieldOptions, - 'label' => 'Leihausrüstungsversicherung', - 'choices' => $options['selectable_rental_insurance'], - ]); + // Rental Insurance - single checkbox (only add if available, JS will show/hide when rentals selected) + if (0 < count($options['selectable_rental_insurance'])) { + $form->add('rentalInsurance', ChoiceType::class, [ + ...$commonChoiceFieldOptions, + 'label' => false, + 'choices' => $options['selectable_rental_insurance'], + ]); + } // Transportation $transportationChoiceAttributes = function (?Service $service) use ($options) { diff --git a/templates/booking/edit.html.twig b/templates/booking/edit.html.twig index d2fa295..aa780fb 100644 --- a/templates/booking/edit.html.twig +++ b/templates/booking/edit.html.twig @@ -210,14 +210,16 @@ {% if child.rentals is defined %}
{{ form_row(child.rentals) }} + {% if child.rentalInsurance is defined %} +
+ {{ form_row(child.rentalInsurance) }} +
+ {% endif %}
{% endif %}
{{ form_row(child.parking) }}
-
- {{ form_row(child.rentalInsurance) }} -
{% if not travelData.additionalServicesMutable %}