fix: show rental insurance field only when applicable

This commit is contained in:
Björn Fromme
2025-11-11 15:39:56 +01:00
parent 111cda95f3
commit beaccd93e0
2 changed files with 13 additions and 9 deletions
+8 -6
View File
@@ -256,12 +256,14 @@ class ParticipantType extends AbstractType
'choices' => $options['selectable_parking'], 'choices' => $options['selectable_parking'],
]); ]);
// Rental Insurance - single checkbox (always add, JS will show/hide when rentals selected) // Rental Insurance - single checkbox (only add if available, JS will show/hide when rentals selected)
$form->add('rentalInsurance', ChoiceType::class, [ if (0 < count($options['selectable_rental_insurance'])) {
...$commonChoiceFieldOptions, $form->add('rentalInsurance', ChoiceType::class, [
'label' => 'Leihausrüstungsversicherung', ...$commonChoiceFieldOptions,
'choices' => $options['selectable_rental_insurance'], 'label' => false,
]); 'choices' => $options['selectable_rental_insurance'],
]);
}
// Transportation // Transportation
$transportationChoiceAttributes = function (?Service $service) use ($options) { $transportationChoiceAttributes = function (?Service $service) use ($options) {
+5 -3
View File
@@ -210,14 +210,16 @@
{% if child.rentals is defined %} {% if child.rentals is defined %}
<div {{ stimulus_target('checkbox-toggle', 'checkboxGroup') }}> <div {{ stimulus_target('checkbox-toggle', 'checkboxGroup') }}>
{{ form_row(child.rentals) }} {{ form_row(child.rentals) }}
{% if child.rentalInsurance is defined %}
<div class="mt-2" {{ stimulus_target('checkbox-toggle', 'container') }}>
{{ form_row(child.rentalInsurance) }}
</div>
{% endif %}
</div> </div>
{% endif %} {% endif %}
<div {{ stimulus_target('select-toggle--parking', 'container') }}> <div {{ stimulus_target('select-toggle--parking', 'container') }}>
{{ form_row(child.parking) }} {{ form_row(child.parking) }}
</div> </div>
<div {{ stimulus_target('checkbox-toggle', 'container') }}>
{{ form_row(child.rentalInsurance) }}
</div>
</div> </div>
{% if not travelData.additionalServicesMutable %} {% if not travelData.additionalServicesMutable %}
<div class="absolute inset-0 cursor-not-allowed"></div> <div class="absolute inset-0 cursor-not-allowed"></div>