feat: prevent editing of applicant's personal data in booking
This commit is contained in:
@@ -38,6 +38,7 @@ final class BookingType extends AbstractType
|
||||
'additional_services_mutable' => $travelData->additionalServicesMutable,
|
||||
'transportation_services_mutable' => $travelData->transportationServicesMutable,
|
||||
'pickups_mutable' => $travelData->pickupsMutable,
|
||||
'applicant_id' => $data->booking->applicant->personId,
|
||||
|
||||
],
|
||||
'allow_add' => false,
|
||||
|
||||
@@ -21,54 +21,6 @@ class ParticipantType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('firstName', TextType::class, [
|
||||
'label' => 'Vorname',
|
||||
])
|
||||
->add('lastName', TextType::class, [
|
||||
'label' => 'Nachname',
|
||||
])
|
||||
->add('dateOfBirth', BirthdayType::class, [
|
||||
'label' => 'Geburtsdatum',
|
||||
'html5' => true,
|
||||
'widget' => 'single_text',
|
||||
'input' => 'datetime_immutable',
|
||||
])
|
||||
->add('gender', ChoiceType::class, [
|
||||
'label' => 'Geschlecht',
|
||||
'required' => false,
|
||||
'placeholder' => 'keine Angabe',
|
||||
'choices' => [
|
||||
'männlich' => 'M',
|
||||
'weiblich' => 'W',
|
||||
'divers' => 'D',
|
||||
],
|
||||
])
|
||||
->add('nationality', CountryType::class, [
|
||||
'label' => 'Nationalität',
|
||||
'property' => 'nationality',
|
||||
'preferred_choices' => ['D', 'A', 'CH'],
|
||||
])
|
||||
->add('email', EmailType::class, [
|
||||
'label' => 'E-Mail',
|
||||
])
|
||||
->add('mobile', TextType::class, [
|
||||
'label' => 'Telefon (mobil)',
|
||||
])
|
||||
->add('height', IntegerType::class, [
|
||||
'label' => 'Körpergröße [cm]',
|
||||
'required' => false,
|
||||
])
|
||||
->add('shoeSize', IntegerType::class, [
|
||||
'label' => 'Schuhgröße',
|
||||
'required' => false,
|
||||
])
|
||||
->add('weight', IntegerType::class, [
|
||||
'label' => 'Gewicht [kg]',
|
||||
'required' => false,
|
||||
])
|
||||
;
|
||||
|
||||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options) {
|
||||
/** @var ParticipantData $participantData */
|
||||
$participantData = $event->getData();
|
||||
@@ -76,6 +28,90 @@ class ParticipantType extends AbstractType
|
||||
|
||||
$form = $event->getForm();
|
||||
|
||||
// $personalDataMutable = $options['personal_data_mutable']
|
||||
// && $participantData->personId !== $options['applicant_id'];
|
||||
$personalDataMutable = $options['personal_data_mutable'];
|
||||
|
||||
$form
|
||||
->add('firstName', TextType::class, [
|
||||
'label' => 'Vorname',
|
||||
'attr' => [
|
||||
'readonly' => false === $personalDataMutable,
|
||||
]
|
||||
])
|
||||
->add('lastName', TextType::class, [
|
||||
'label' => 'Nachname',
|
||||
'attr' => [
|
||||
'readonly' => false === $personalDataMutable,
|
||||
]
|
||||
])
|
||||
->add('dateOfBirth', BirthdayType::class, [
|
||||
'label' => 'Geburtsdatum',
|
||||
'html5' => true,
|
||||
'widget' => 'single_text',
|
||||
'input' => 'datetime_immutable',
|
||||
'attr' => [
|
||||
'readonly' => false === $personalDataMutable,
|
||||
]
|
||||
])
|
||||
->add('gender', ChoiceType::class, [
|
||||
'label' => 'Geschlecht',
|
||||
'required' => false,
|
||||
'placeholder' => 'keine Angabe',
|
||||
'choices' => [
|
||||
'männlich' => 'M',
|
||||
'weiblich' => 'W',
|
||||
'divers' => 'D',
|
||||
],
|
||||
'attr' => [
|
||||
'readonly' => false === $personalDataMutable,
|
||||
'style' => false === $personalDataMutable ? 'pointer-events: none' : null,
|
||||
]
|
||||
])
|
||||
->add('nationality', CountryType::class, [
|
||||
'label' => 'Nationalität',
|
||||
'property' => 'nationality',
|
||||
'preferred_choices' => ['D', 'A', 'CH'],
|
||||
'attr' => [
|
||||
'readonly' => false === $personalDataMutable,
|
||||
'style' => false === $personalDataMutable ? 'pointer-events: none' : null,
|
||||
]
|
||||
])
|
||||
->add('email', EmailType::class, [
|
||||
'label' => 'E-Mail',
|
||||
'attr' => [
|
||||
'readonly' => false === $personalDataMutable,
|
||||
]
|
||||
])
|
||||
->add('mobile', TextType::class, [
|
||||
'label' => 'Telefon (mobil)',
|
||||
'attr' => [
|
||||
'readonly' => false === $personalDataMutable,
|
||||
]
|
||||
])
|
||||
->add('height', IntegerType::class, [
|
||||
'label' => 'Körpergröße [cm]',
|
||||
'required' => false,
|
||||
'attr' => [
|
||||
'readonly' => false === $personalDataMutable,
|
||||
]
|
||||
])
|
||||
->add('shoeSize', IntegerType::class, [
|
||||
'label' => 'Schuhgröße',
|
||||
'required' => false,
|
||||
'attr' => [
|
||||
'readonly' => false === $personalDataMutable,
|
||||
]
|
||||
])
|
||||
->add('weight', IntegerType::class, [
|
||||
'label' => 'Gewicht [kg]',
|
||||
'required' => false,
|
||||
'attr' => [
|
||||
'readonly' => false === $personalDataMutable,
|
||||
]
|
||||
])
|
||||
;
|
||||
|
||||
$commonChoiceFieldOptions = [
|
||||
'required' => false,
|
||||
'multiple' => true,
|
||||
@@ -268,6 +304,7 @@ class ParticipantType extends AbstractType
|
||||
'additional_services_mutable' => true,
|
||||
'transportation_services_mutable' => true,
|
||||
'pickups_mutable' => true,
|
||||
'applicant_id' => null,
|
||||
'anti_xss' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user