wip: service descriptions and car license plate field

This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent b84997d058
commit 84f4481ef0
12 changed files with 623 additions and 5 deletions
@@ -108,6 +108,20 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
),
'choice_value' => 'id',
'choice_label' => fn (?Service $service) => $this->formatServiceLabelWithPrice($service),
'choice_attr' => function (?Service $service) {
if (null === $service) {
return [];
}
$attributes = [];
// Add service description as data attribute for frontend use
if (null !== $service->description && '' !== trim($service->description)) {
$attributes['data-description'] = $service->description;
}
return $attributes;
},
];
// Additional services field provider - provides age-appropriate additional services with mandatory pre-selection
@@ -141,6 +155,11 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
$attributes['title'] = 'Diese Leistung ist nicht abwählbar';
}
// Add service description as data attribute for frontend use
if (null !== $service->description && '' !== trim($service->description)) {
$attributes['data-description'] = $service->description;
}
return $attributes;
},
];
@@ -181,6 +200,20 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
),
'choice_value' => 'id',
'choice_label' => fn (?Service $service) => $this->formatServiceLabelWithPrice($service),
'choice_attr' => function (?Service $service) {
if (null === $service) {
return [];
}
$attributes = [];
// Add service description as data attribute for frontend use
if (null !== $service->description && '' !== trim($service->description)) {
$attributes['data-description'] = $service->description;
}
return $attributes;
},
];
// Rental insurance field provider - provides rental insurance options when rental services are selected
@@ -188,6 +221,19 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
'label' => $this->getRentalInsuranceCheckboxLabel($bookingDto->travel->getAdditionalServicesBySubTypes(Constants::TOKEN_RENTAL_INSURANCE, true, true)),
'required' => false,
'property_path' => 'rentalInsuranceSelected',
'help' => $this->getRentalInsuranceDescription($bookingDto->travel->getAdditionalServicesBySubTypes(Constants::TOKEN_RENTAL_INSURANCE, true, true)),
];
// License plate field provider - provides text input for vehicle license plate when parking is selected
$this->fieldOptionProviders['licensePlate'] = fn (BookingDtoInterface $bookingDto, int $participantIndex, array $options = []) => [
'label' => 'Kennzeichen',
'required' => false,
'attr' => [
'placeholder' => 'z.B. AB-CD 123',
'maxlength' => 20,
],
'help' => 'Bitte gib das Kennzeichen deines Fahrzeugs an. Du kannst es aber auch später nachreichen.',
'clean_xss' => true,
];
// Skipass field provider - provides age-appropriate skipass options from travel data filtered by date range
@@ -207,6 +253,20 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
),
'choice_value' => 'id',
'choice_label' => fn (?Service $service) => $this->formatServiceLabelWithPrice($service),
'choice_attr' => function (?Service $service) {
if (null === $service) {
return [];
}
$attributes = [];
// Add service description as data attribute for frontend use
if (null !== $service->description && '' !== trim($service->description)) {
$attributes['data-description'] = $service->description;
}
return $attributes;
},
];
// Room remarks field provider - provides textarea for room-specific remarks (only for 'mbz' rooms)
@@ -494,6 +554,20 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
return 'Leihmaterial-Versicherung';
}
$rentalInsuranceService = reset($rentalInsuranceServices); // Get the first (and only) rental insurance service
return $this->formatServiceLabelWithPrice($rentalInsuranceService);
}
/**
* Gets the rental insurance description for help text.
*/
private function getRentalInsuranceDescription(array $rentalInsuranceServices): ?string
{
if (empty($rentalInsuranceServices)) {
return null;
}
$rentalInsuranceService = reset($rentalInsuranceServices); // Get the first (and only) rental insurance service
return $rentalInsuranceService->description;
}
}