fix: correctly distinguish between first participant and applicant
This commit is contained in:
@@ -7,7 +7,6 @@ namespace App\Form\Service;
|
||||
use App\BusProNet\Utility\DirectionMapper;
|
||||
use App\Form\Service\Abstract\AbstractFieldStateProvider;
|
||||
use App\Form\Service\Condition\AgeRangeCondition;
|
||||
use App\Form\Service\Condition\ApplicantCondition;
|
||||
use App\Form\Service\Condition\AuthenticatedUserPersonalDataCondition;
|
||||
use App\Form\Service\Condition\BabyAgeCondition;
|
||||
use App\Form\Service\Condition\BookingEligibilityCondition;
|
||||
@@ -16,6 +15,7 @@ use App\Form\Service\Condition\CompositeCondition;
|
||||
use App\Form\Service\Condition\DateOfBirthProvidedCondition;
|
||||
use App\Form\Service\Condition\FieldValueCondition;
|
||||
use App\Form\Service\Condition\FinalBookingOnlyCondition;
|
||||
use App\Form\Service\Condition\FirstParticipantCondition;
|
||||
use App\Form\Service\Condition\MultipleParticipantsCondition;
|
||||
use App\Form\Service\Condition\RentalSelectionCondition;
|
||||
use App\Form\Service\Condition\RoomSelectionCondition;
|
||||
@@ -107,10 +107,10 @@ class CreateFieldStateProvider extends AbstractFieldStateProvider
|
||||
'static_text' => $authenticatedUserCondition,
|
||||
];
|
||||
|
||||
// Mobile field: static text for authenticated users, required for guest applicants
|
||||
// Mobile field: static text for authenticated users, required for first participant (guest bookings)
|
||||
$this->fieldStateConditions['mobile'] = [
|
||||
'static_text' => $authenticatedUserCondition,
|
||||
'required' => new ApplicantCondition(),
|
||||
'required' => new FirstParticipantCondition(),
|
||||
];
|
||||
|
||||
// Address subfields - must render as static text to prevent creating duplicate BPN records
|
||||
@@ -194,13 +194,13 @@ class CreateFieldStateProvider extends AbstractFieldStateProvider
|
||||
// Bulk insurance booking conditions
|
||||
$bulkInsuranceBookingCondition = new BulkInsuranceBookingCondition();
|
||||
|
||||
// Show bulk insurance booking checkbox ONLY for applicant (index 0) when:
|
||||
// Show bulk insurance booking checkbox ONLY for first participant (index 0) when:
|
||||
// - Date of birth is provided
|
||||
// - There are multiple participants (bulk assignment is meaningless for single participant)
|
||||
$this->fieldStateConditions['bulkInsuranceBooking'] = [
|
||||
'hidden' => CompositeCondition::or(
|
||||
CompositeCondition::not($dateOfBirthProvidedCondition), // Hide until date of birth provided
|
||||
CompositeCondition::not(new ApplicantCondition()), // Hide for non-applicants
|
||||
CompositeCondition::not(new FirstParticipantCondition()), // Hide for non-first participants
|
||||
CompositeCondition::not(new MultipleParticipantsCondition()) // Hide when only one participant
|
||||
),
|
||||
];
|
||||
@@ -274,11 +274,11 @@ class CreateFieldStateProvider extends AbstractFieldStateProvider
|
||||
'hidden' => FieldValueCondition::equals('parking', false),
|
||||
];
|
||||
|
||||
// Make address field required for applicant (participant index 0)
|
||||
// Make address field required for first participant (index 0)
|
||||
// Also render as static text for authenticated users to prevent duplicate BPN records
|
||||
$this->fieldStateConditions['address'] = [
|
||||
'static_text' => $authenticatedUserCondition,
|
||||
'required' => new ApplicantCondition(),
|
||||
'required' => new FirstParticipantCondition(),
|
||||
];
|
||||
|
||||
// Room assignment field:
|
||||
|
||||
Reference in New Issue
Block a user