diff --git a/assets/styles/components/forms.css b/assets/styles/components/forms.css index 9d53970..c607a36 100644 --- a/assets/styles/components/forms.css +++ b/assets/styles/components/forms.css @@ -21,6 +21,7 @@ label.required:after { @apply border-red-500; } -input[disabled] { +input[disabled], +input[readonly] { @apply cursor-not-allowed; } diff --git a/src/Form/BookingType.php b/src/Form/BookingType.php index 9f06924..f553bc1 100644 --- a/src/Form/BookingType.php +++ b/src/Form/BookingType.php @@ -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, diff --git a/src/Form/ParticipantType.php b/src/Form/ParticipantType.php index 532fa0b..0fbd248 100644 --- a/src/Form/ParticipantType.php +++ b/src/Form/ParticipantType.php @@ -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, ]); } diff --git a/templates/booking/edit.html.twig b/templates/booking/edit.html.twig index ef072b3..ce8d68f 100644 --- a/templates/booking/edit.html.twig +++ b/templates/booking/edit.html.twig @@ -37,13 +37,13 @@