diff --git a/src/Form/Service/EditFieldStateProvider.php b/src/Form/Service/EditFieldStateProvider.php index 26635d9..8ecce29 100644 --- a/src/Form/Service/EditFieldStateProvider.php +++ b/src/Form/Service/EditFieldStateProvider.php @@ -7,6 +7,7 @@ namespace App\Form\Service; use App\BusProNet\Utility\DirectionMapper; use App\Form\Model\BookingDto; use App\Form\Service\Abstract\AbstractFieldStateProvider; +use App\Form\Service\Contract\FieldConditionInterface; use App\Form\Service\Condition\AdditionalServicesMutabilityCondition; use App\Form\Service\Condition\AgeRangeCondition; use App\Form\Service\Condition\BookingModeCondition; @@ -65,8 +66,26 @@ class EditFieldStateProvider extends AbstractFieldStateProvider $personalDataMutabilityCondition ); - // Core identity fields: static text if first participant in non-internal agency OR BPN indicates not mutable - foreach (['firstName', 'lastName', 'dateOfBirth', 'gender', 'nationality'] as $field) { + // TODO: Remove the block below and move 'firstName', 'lastName', 'dateOfBirth' into the + // 'gender'/'nationality' loop once BPN reliably handles name and date-of-birth changes for participants. + // Until then, name and DOB are always read-only for non-internal agency regardless of the BPN flag. + $corePersonalDataReadOnlyCondition = new class implements FieldConditionInterface { + public function evaluate(BookingDto $bookingDto, int $participantIndex, array $formData): bool + { + return !$bookingDto->isInternalAgencyBooking(); + } + + public function getDependentFields(): array { return []; } + + public function getDescription(): string { return 'Name and DOB always read-only for non-internal agency (temporary)'; } + }; + foreach (['firstName', 'lastName', 'dateOfBirth'] as $field) { + $this->fieldStateConditions[$field] = ['static_text' => $corePersonalDataReadOnlyCondition]; + } + // END TODO block + + // Gender and nationality: static text if first participant in non-internal agency OR BPN indicates not mutable + foreach (['gender', 'nationality'] as $field) { $this->fieldStateConditions[$field] = [ 'static_text' => $personalDataHiddenCondition, ];