wip: booking process, refactor participant room assignment logic

This commit is contained in:
Björn Fromme
2025-07-18 16:43:02 +02:00
parent b4db0cb8f2
commit b3c633dccb
2 changed files with 6 additions and 11 deletions
@@ -69,7 +69,8 @@ class CreateStep2Controller extends AbstractController
}
/**
* Handles HTMX requests for dynamic form updates when room selections change.
* Handles HTMX requests for dynamic form updates when room selections change by submitting the form
* without validation and returning a freshly rendered instance.
*/
#[Route('/bookings/create/participants/refresh', name: 'app_booking_create_step_2_refresh', methods: ['POST'])]
public function refreshParticipantForm(Request $request): Response
@@ -84,8 +85,6 @@ class CreateStep2Controller extends AbstractController
$form->handleRequest($request);
$this->bookingService->saveBookingCreateDto($request, $bookingCreateDto);
return $this->renderBlock('booking/create_step_2.html.twig', 'participants_form', [
'form' => $form->createView(),
]);
+4 -8
View File
@@ -22,16 +22,12 @@ class BookingCreateStep2Type extends AbstractType
public function onPreSetData(FormEvent $event): void
{
/** @var BookingCreateDto $bookingCreateDto */
$bookingCreateDto = $event->getData();
/** @var BookingCreateDto $data */
$data = $event->getData();
$form = $event->getForm();
if (null === $bookingCreateDto) {
return;
}
$adapter = new ParticipantDataAdapter($bookingCreateDto->participants);
$roomChoices = $this->generateRoomChoices($adapter, $bookingCreateDto->getSelectedRooms());
$adapter = new ParticipantDataAdapter($data->participants);
$roomChoices = $this->generateRoomChoices($adapter, $data->getSelectedRooms());
$this->addParticipantsField($form, $roomChoices);
}