diff --git a/src/Form/Service/Condition/BookingModeCondition.php b/src/Form/Service/Condition/BookingModeCondition.php new file mode 100644 index 0000000..1df1671 --- /dev/null +++ b/src/Form/Service/Condition/BookingModeCondition.php @@ -0,0 +1,43 @@ +mode === $bookingDto->getMode(); + } + + public function getDependentFields(): array + { + return []; + } + + public function getDescription(): string + { + return sprintf('Returns true when booking is in %s mode', $this->mode); + } +} diff --git a/src/Form/Service/CreateFieldStateProvider.php b/src/Form/Service/CreateFieldStateProvider.php index 82c4837..5f406e0 100644 --- a/src/Form/Service/CreateFieldStateProvider.php +++ b/src/Form/Service/CreateFieldStateProvider.php @@ -263,8 +263,11 @@ class CreateFieldStateProvider extends AbstractFieldStateProvider 'required' => new ApplicantCondition(), ]; - // Render assignedRoomId field as static text when only one room type is selected (auto-assigned by RoomAssignmentService) + // Room assignment field: + // - Hidden until date of birth is provided (age determines room eligibility, e.g., Baby rooms) + // - Rendered as static text when only one room type is selected (auto-assigned by RoomAssignmentService) $this->fieldStateConditions['assignedRoomId'] = [ + 'hidden' => CompositeCondition::not($dateOfBirthProvidedCondition), 'static_text' => new SingleRoomTypeCondition(), ]; diff --git a/src/Form/Service/EditFieldStateProvider.php b/src/Form/Service/EditFieldStateProvider.php index 27aae15..23ba391 100644 --- a/src/Form/Service/EditFieldStateProvider.php +++ b/src/Form/Service/EditFieldStateProvider.php @@ -5,10 +5,12 @@ declare(strict_types=1); namespace App\Form\Service; use App\BusProNet\Utility\DirectionMapper; +use App\Form\Model\BookingDto; use App\Form\Service\Abstract\AbstractFieldStateProvider; use App\Form\Service\Condition\AdditionalServicesMutabilityCondition; use App\Form\Service\Condition\ApplicantCondition; use App\Form\Service\Condition\AuthenticatedUserPersonalDataCondition; +use App\Form\Service\Condition\BookingModeCondition; use App\Form\Service\Condition\CompositeCondition; use App\Form\Service\Condition\DateOfBirthProvidedCondition; use App\Form\Service\Condition\FieldValueCondition; @@ -16,7 +18,6 @@ use App\Form\Service\Condition\PersonalDataMutabilityCondition; use App\Form\Service\Condition\PickupsMutabilityCondition; use App\Form\Service\Condition\RentalSelectionCondition; use App\Form\Service\Condition\ServiceSubTypeCondition; -use App\Form\Service\Condition\SingleRoomTypeCondition; use App\Form\Service\Condition\SkiPassSelectionCondition; use App\Form\Service\Condition\TransportationServicesMutabilityCondition; @@ -97,10 +98,10 @@ class EditFieldStateProvider extends AbstractFieldStateProvider 'static_text' => $personalDataHiddenCondition, ]; - // Render assignedRoomId field as static text when only one room type is selected (auto-assigned by RoomAssignmentService) - // Same logic as create mode - render as static text when only one room type available + // Room assignments are fixed in edit mode - always render as static text + // The assignedRoomId value passes through unchanged from the loaded booking data $this->fieldStateConditions['assignedRoomId'] = [ - 'static_text' => new SingleRoomTypeCondition(), + 'static_text' => new BookingModeCondition(BookingDto::MODE_EDIT), ]; // Conditional visibility for service fields (same as create flow) diff --git a/templates/booking/_participant_form.html.twig b/templates/booking/_participant_form.html.twig index a933582..6116f06 100644 --- a/templates/booking/_participant_form.html.twig +++ b/templates/booking/_participant_form.html.twig @@ -134,22 +134,24 @@ {% endif %} - {# Room assignment #} -