feat: show room pricing details

This commit is contained in:
Björn Fromme
2025-09-30 16:47:17 +02:00
parent 009eabd09c
commit 71b42786f7
5 changed files with 17 additions and 9 deletions
+2
View File
@@ -11,6 +11,8 @@ class RoomSelectionDto
public ?string $roomLabel = null;
public ?float $roomPrice = null;
public ?int $quantity = null;
public int $maxQuantity = 100;
+4 -5
View File
@@ -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,
]);
}
}