feat: improved handling of fields to be rendered as static text

This commit is contained in:
Björn Fromme
2026-03-16 11:59:11 +01:00
parent 5d69e4a8aa
commit ff39bf365c
8 changed files with 211 additions and 82 deletions
+19 -16
View File
@@ -23,11 +23,12 @@ use App\Service\ParticipantEligibilityService;
/**
* Field state provider for the booking create workflow.
*
* This service calculates dynamic field states (readonly, disabled, etc.)
* This service calculates dynamic field states (readonly, disabled, static_text, etc.)
* for participant fields in the create flow. It extends the common field
* state functionality provided by AbstractFieldStateProvider.
*
* Current field state conditions:
* - Personal data fields render as static text for authenticated users (prevents duplicate BPN records)
* - Body dimension fields are hidden unless rental services are selected
* - Age-dependent service fields are hidden until birth date is provided
* - Transportation pickup fields are hidden by default, shown only when transportation type is BUS
@@ -75,58 +76,58 @@ class CreateFieldStateProvider extends AbstractFieldStateProvider
$skiPassCondition = new SkiPassSelectionCondition();
// Authenticated user personal data protection
// Hide personal data fields for participants linked to BPN accounts (prevents duplicate records)
// Render personal data fields as static text for participants linked to BPN accounts (prevents duplicate records)
$authenticatedUserCondition = new AuthenticatedUserPersonalDataCondition();
$this->fieldStateConditions['firstName'] = [
'hidden' => $authenticatedUserCondition,
'static_text' => $authenticatedUserCondition,
];
$this->fieldStateConditions['lastName'] = [
'hidden' => $authenticatedUserCondition,
'static_text' => $authenticatedUserCondition,
];
$this->fieldStateConditions['gender'] = [
'hidden' => $authenticatedUserCondition,
'static_text' => $authenticatedUserCondition,
];
$this->fieldStateConditions['nationality'] = [
'hidden' => $authenticatedUserCondition,
'static_text' => $authenticatedUserCondition,
];
$this->fieldStateConditions['dateOfBirth'] = [
'hidden' => $authenticatedUserCondition,
'static_text' => $authenticatedUserCondition,
];
$this->fieldStateConditions['email'] = [
'hidden' => $authenticatedUserCondition,
'static_text' => $authenticatedUserCondition,
];
// Mobile field: hidden for authenticated users, required for guest applicants
// Mobile field: static text for authenticated users, required for guest applicants
$this->fieldStateConditions['mobile'] = [
'hidden' => $authenticatedUserCondition,
'static_text' => $authenticatedUserCondition,
'required' => new ApplicantCondition(),
];
// Address subfields - must be hidden to prevent creating duplicate BPN records
// Address subfields - must render as static text to prevent creating duplicate BPN records
$this->fieldStateConditions['address.street'] = [
'hidden' => $authenticatedUserCondition,
'static_text' => $authenticatedUserCondition,
];
$this->fieldStateConditions['address.postCode'] = [
'hidden' => $authenticatedUserCondition,
'static_text' => $authenticatedUserCondition,
];
$this->fieldStateConditions['address.city'] = [
'hidden' => $authenticatedUserCondition,
'static_text' => $authenticatedUserCondition,
];
$this->fieldStateConditions['address.country'] = [
'hidden' => $authenticatedUserCondition,
'static_text' => $authenticatedUserCondition,
];
$this->fieldStateConditions['address.district'] = [
'hidden' => $authenticatedUserCondition,
'static_text' => $authenticatedUserCondition,
];
// Note: Body dimensions (height, weight, shoeSize) are NOT hidden for authenticated users
@@ -255,7 +256,9 @@ class CreateFieldStateProvider extends AbstractFieldStateProvider
];
// Make address field required for applicant (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(),
];