diff --git a/src/Form/Model/RoomSelectionDto.php b/src/Form/Model/RoomSelectionDto.php index c3c10e9..bf88b9d 100644 --- a/src/Form/Model/RoomSelectionDto.php +++ b/src/Form/Model/RoomSelectionDto.php @@ -11,6 +11,8 @@ class RoomSelectionDto public ?string $roomLabel = null; + public ?float $roomPrice = null; + public ?int $quantity = null; public int $maxQuantity = 100; diff --git a/src/Form/RoomSelectType.php b/src/Form/RoomSelectType.php index c4c3a51..439b5cf 100644 --- a/src/Form/RoomSelectType.php +++ b/src/Form/RoomSelectType.php @@ -17,15 +17,15 @@ class RoomSelectType extends AbstractType { $builder ->add('roomId', HiddenType::class) - ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options) { + ->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) { $data = $event->getData(); $form = $event->getForm(); // Build label with pricing $label = 'Anzahl '.$data->roomLabel; - if (null !== $options['room_price']) { - $formattedPrice = number_format((float) $options['room_price'], 2, ',', '.'); - $label .= sprintf(' (€%s pro Nacht)', $formattedPrice); + if (null !== $data->roomPrice) { + $formattedPrice = number_format((float) $data->roomPrice, 2, ',', '.'); + $label .= sprintf(' (€%s pro Person)', $formattedPrice); } $form->add('quantity', ChoiceType::class, [ @@ -40,7 +40,6 @@ class RoomSelectType extends AbstractType { $resolver->setDefaults([ 'data_class' => RoomSelectionDto::class, - 'room_price' => null, ]); } } diff --git a/src/Service/BookingService.php b/src/Service/BookingService.php index fb4387e..13ddf2b 100644 --- a/src/Service/BookingService.php +++ b/src/Service/BookingService.php @@ -159,6 +159,7 @@ class BookingService $selection = new RoomSelectionDto(); $selection->roomId = $room->id; $selection->roomLabel = $room->label; + $selection->roomPrice = $room->price; $selection->maxQuantity = $room->available; $selection->capacity = $room->minPax; $selection->quantity = $roomsIdsAndQuantities[$room->id] ?? 0; diff --git a/templates/booking/_summary.html.twig b/templates/booking/_summary.html.twig index c969b2d..faf1666 100644 --- a/templates/booking/_summary.html.twig +++ b/templates/booking/_summary.html.twig @@ -18,16 +18,21 @@