wip: booking process, refactor participant room assignment logic
This commit is contained in:
@@ -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'])]
|
#[Route('/bookings/create/participants/refresh', name: 'app_booking_create_step_2_refresh', methods: ['POST'])]
|
||||||
public function refreshParticipantForm(Request $request): Response
|
public function refreshParticipantForm(Request $request): Response
|
||||||
@@ -84,8 +85,6 @@ class CreateStep2Controller extends AbstractController
|
|||||||
|
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
$this->bookingService->saveBookingCreateDto($request, $bookingCreateDto);
|
|
||||||
|
|
||||||
return $this->renderBlock('booking/create_step_2.html.twig', 'participants_form', [
|
return $this->renderBlock('booking/create_step_2.html.twig', 'participants_form', [
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -22,16 +22,12 @@ class BookingCreateStep2Type extends AbstractType
|
|||||||
|
|
||||||
public function onPreSetData(FormEvent $event): void
|
public function onPreSetData(FormEvent $event): void
|
||||||
{
|
{
|
||||||
/** @var BookingCreateDto $bookingCreateDto */
|
/** @var BookingCreateDto $data */
|
||||||
$bookingCreateDto = $event->getData();
|
$data = $event->getData();
|
||||||
$form = $event->getForm();
|
$form = $event->getForm();
|
||||||
|
|
||||||
if (null === $bookingCreateDto) {
|
$adapter = new ParticipantDataAdapter($data->participants);
|
||||||
return;
|
$roomChoices = $this->generateRoomChoices($adapter, $data->getSelectedRooms());
|
||||||
}
|
|
||||||
|
|
||||||
$adapter = new ParticipantDataAdapter($bookingCreateDto->participants);
|
|
||||||
$roomChoices = $this->generateRoomChoices($adapter, $bookingCreateDto->getSelectedRooms());
|
|
||||||
$this->addParticipantsField($form, $roomChoices);
|
$this->addParticipantsField($form, $roomChoices);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user