wip: additional services with constraints
This commit is contained in:
@@ -92,15 +92,56 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'required' => false,
|
||||
'choices' => array_reduce(
|
||||
$bookingDto->travel->getAdditionalServicesByGroup(Constants::TOKEN_COURSES),
|
||||
function (array $choices, Service $service) {
|
||||
$choices[$service->label] = $service->id;
|
||||
'choices' => $bookingDto->travel->getAdditionalServicesBySubTypes(Constants::TOKEN_COURSES),
|
||||
'choice_label' => 'label',
|
||||
];
|
||||
|
||||
return $choices;
|
||||
},
|
||||
[]
|
||||
),
|
||||
// Additional services field provider - provides additional services with mandatory pre-selection
|
||||
$this->fieldOptionProviders['additionalServices'] = fn (BookingDtoInterface $bookingDto) => [
|
||||
'label' => 'Zusatzleistungen',
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'required' => false,
|
||||
'choices' => $bookingDto->travel->getAdditionalServicesBySubTypes(Constants::TOKEN_ADDITIONAL),
|
||||
'choice_value' => 'id',
|
||||
'choice_label' => 'label',
|
||||
'choice_attr' => function (?Service $service) {
|
||||
if (null === $service) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$attributes = [];
|
||||
|
||||
// Pre-select and make readonly for mandatory services
|
||||
if (true === $service->mandatory) {
|
||||
$attributes['checked'] = true;
|
||||
$attributes['readonly'] = true;
|
||||
$attributes['class'] = 'text-pink';
|
||||
$attributes['title'] = 'Diese Leistung ist nicht abwählbar';
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
},
|
||||
];
|
||||
|
||||
// Board field provider - provides available board options from travel data
|
||||
$this->fieldOptionProviders['board'] = fn (BookingDtoInterface $bookingDto) => [
|
||||
'label' => 'Verpflegung',
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'required' => false,
|
||||
'choices' => $bookingDto->travel->getAdditionalServicesBySubTypes(Constants::TOKEN_BOARD),
|
||||
'choice_label' => 'label',
|
||||
];
|
||||
|
||||
// Rentals field provider - provides available rental options from travel data filtered by date range
|
||||
$this->fieldOptionProviders['rentals'] = fn (BookingDtoInterface $bookingDto) => [
|
||||
'label' => 'Leihmaterial',
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'required' => false,
|
||||
'choices' => $bookingDto->travel->getAdditionalServicesBySubTypes(Constants::TOKEN_RENTALS, true, true),
|
||||
'choice_label' => 'label',
|
||||
];
|
||||
|
||||
// Future field providers would be added here, for example:
|
||||
|
||||
Reference in New Issue
Block a user