fix: keep browser history intact when navigating between cards view and participant form

This commit is contained in:
Björn Fromme
2026-03-16 11:59:11 +01:00
parent bb20176c76
commit f3ea6734a1
7 changed files with 136 additions and 70 deletions
+30 -22
View File
@@ -188,7 +188,8 @@ class IndexController extends AbstractController
return $this->htmxOobResponse(
'booking/edit/index.html.twig',
['participant_cards', 'booking_summary'],
$templateData
$templateData,
$this->generateUrl('app_booking_edit', ['id' => $id])
);
}
@@ -274,27 +275,34 @@ class IndexController extends AbstractController
// Fetch mutable data for form constraints
$mutableData = $this->travelDataService->getMutabilityData($bookingData->dateId);
// Render form and sidebar with OOB swap using htmxOobResponse
// This ensures both initial load and refresh use the same block-based rendering
return $this->htmxOobResponse(
'booking/_participant_form.html.twig',
['participant_form', 'booking_summary'],
[
'form' => $form->createView(),
'participantIndex' => $index,
'bookingDto' => $bookingDto,
'bookingData' => $bookingData,
'mutableData' => $mutableData,
'summaryData' => $summaryData,
'pricingData' => $summary['pricing'],
'refreshRouteName' => 'app_booking_edit_participant_refresh',
'refreshRouteParams' => ['id' => $id, 'index' => $index],
'submitRouteName' => 'app_booking_edit_participant',
'submitRouteParams' => ['id' => $id, 'index' => $index],
'cancelRouteName' => 'app_booking_edit',
'cancelRouteParams' => ['id' => $id],
]
);
$templateData = [
'form' => $form->createView(),
'participantIndex' => $index,
'bookingDto' => $bookingDto,
'bookingData' => $bookingData,
'mutableData' => $mutableData,
'summaryData' => $summaryData,
'pricingData' => $summary['pricing'],
'refreshRouteName' => 'app_booking_edit_participant_refresh',
'refreshRouteParams' => ['id' => $id, 'index' => $index],
'submitRouteName' => 'app_booking_edit_participant',
'submitRouteParams' => ['id' => $id, 'index' => $index],
'cancelRouteName' => 'app_booking_edit',
'cancelRouteParams' => ['id' => $id],
];
// HTMX request: render blocks only with OOB swap
if ($this->isHxRequest($request)) {
return $this->htmxOobResponse(
'booking/_participant_form.html.twig',
['participant_form', 'booking_summary'],
$templateData,
$this->generateUrl('app_booking_edit_participant', ['id' => $id, 'index' => $index])
);
}
// Regular request: render full template
return $this->render('booking/edit/participant.html.twig', $templateData);
}
/**