wip: continue implementation
This commit is contained in:
@@ -24,10 +24,10 @@ class ParticipantData
|
||||
public ?string $gender = null;
|
||||
public ?string $nationality = null;
|
||||
|
||||
#[Assert\Range(notInRangeMessage: 'Bitte einen Wert im Bereich {{ min }}-{{ max }}cm angeben', min: 140, max: 210)]
|
||||
#[Assert\Range(notInRangeMessage: 'Bitte einen Wert im Bereich {{ min }}-{{ max }}cm angeben', min: 150, max: 210)]
|
||||
public ?string $height = null;
|
||||
|
||||
#[Assert\Range(notInRangeMessage: 'Bitte einen Wert im Bereich {{ min }}-{{ max }} angeben', min: 35, max: 49)]
|
||||
#[Assert\Range(notInRangeMessage: 'Bitte einen Wert im Bereich {{ min }}-{{ max }} angeben', min: 37, max: 49)]
|
||||
public ?string $shoeSize = null;
|
||||
|
||||
#[Assert\Range(notInRangeMessage: 'Bitte einen Wert im Bereich {{ min }}-{{ max }}kg angeben', min: 40, max: 130)]
|
||||
|
||||
+128
-133
@@ -21,55 +21,53 @@ class ParticipantType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
if (true === $options['personal_data_mutable']) {
|
||||
$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
|
||||
->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 */
|
||||
@@ -99,8 +97,8 @@ class ParticipantType extends AbstractType
|
||||
},
|
||||
'choice_attr' => function (?Service $service) {
|
||||
$attributes = [
|
||||
'data-available' => $service->available,
|
||||
'data-availabilities-target' => 'field',
|
||||
'data-booking-target' => 'field',
|
||||
'data-action' => 'booking#toggle',
|
||||
];
|
||||
|
||||
// forcibly select mandatory services
|
||||
@@ -131,96 +129,93 @@ class ParticipantType extends AbstractType
|
||||
];
|
||||
|
||||
// Additional services
|
||||
if (true === $options['additional_services_mutable']) {
|
||||
if (0 < count($options['selectable_courses'])) {
|
||||
$form->add('courses', ChoiceType::class, [
|
||||
...$commonChoiceFieldOptions,
|
||||
'label' => 'Kurse',
|
||||
'choices' => $options['selectable_courses'],
|
||||
]);
|
||||
}
|
||||
if (0 < count($options['selectable_services'])) {
|
||||
$form->add('additionalServices', ChoiceType::class, [
|
||||
...$commonChoiceFieldOptions,
|
||||
'label' => 'Zusatzleistungen',
|
||||
'choices' => $options['selectable_services'],
|
||||
]);
|
||||
}
|
||||
if (0 < count($options['selectable_ski_passes'])) {
|
||||
$form->add('skiPass', ChoiceType::class, [
|
||||
...$commonChoiceFieldOptions,
|
||||
'label' => 'Skipass',
|
||||
'choices' => $options['selectable_ski_passes'],
|
||||
]);
|
||||
}
|
||||
if (0 < count($options['selectable_board'])) {
|
||||
$form->add('board', ChoiceType::class, [
|
||||
...$commonChoiceFieldOptions,
|
||||
'label' => 'Verpflegung',
|
||||
'choices' => $options['selectable_board'],
|
||||
]);
|
||||
}
|
||||
if (0 < count($options['selectable_rentals'])) {
|
||||
$form->add('rentals', ChoiceType::class, [
|
||||
...$commonChoiceFieldOptions,
|
||||
'label' => 'Verleih',
|
||||
'choices' => $options['selectable_rentals'],
|
||||
]);
|
||||
}
|
||||
if (0 < count($options['selectable_courses'])) {
|
||||
$form->add('courses', ChoiceType::class, [
|
||||
...$commonChoiceFieldOptions,
|
||||
'label' => 'Kurse',
|
||||
'choices' => $options['selectable_courses'],
|
||||
]);
|
||||
}
|
||||
if (0 < count($options['selectable_services'])) {
|
||||
$form->add('additionalServices', ChoiceType::class, [
|
||||
...$commonChoiceFieldOptions,
|
||||
'label' => 'Zusatzleistungen',
|
||||
'choices' => $options['selectable_services'],
|
||||
]);
|
||||
}
|
||||
if (0 < count($options['selectable_ski_passes'])) {
|
||||
$form->add('skiPass', ChoiceType::class, [
|
||||
...$commonChoiceFieldOptions,
|
||||
'label' => 'Skipass',
|
||||
'choices' => $options['selectable_ski_passes'],
|
||||
]);
|
||||
}
|
||||
if (0 < count($options['selectable_board'])) {
|
||||
$form->add('board', ChoiceType::class, [
|
||||
...$commonChoiceFieldOptions,
|
||||
'label' => 'Verpflegung',
|
||||
'choices' => $options['selectable_board'],
|
||||
]);
|
||||
}
|
||||
if (0 < count($options['selectable_rentals'])) {
|
||||
$form->add('rentals', ChoiceType::class, [
|
||||
...$commonChoiceFieldOptions,
|
||||
'label' => 'Verleih',
|
||||
'choices' => $options['selectable_rentals'],
|
||||
]);
|
||||
}
|
||||
|
||||
// Transportation
|
||||
if (true === $options['transportation_services_mutable']) {
|
||||
$form
|
||||
->add('transportationServiceTo', ChoiceType::class, [
|
||||
...$commonChoiceFieldOptions,
|
||||
'label' => 'Anreise',
|
||||
'multiple' => false,
|
||||
'choices' => $options['selectable_transportation_services_to'],
|
||||
'choice_attr' => function (?Service $service) {
|
||||
return [
|
||||
'data-available' => $service->available,
|
||||
'data-availabilities-target' => 'field',
|
||||
'data-action' => 'select-toggle#toggle',
|
||||
'data-select-toggle-value' => $service->subType,
|
||||
];
|
||||
},
|
||||
])
|
||||
->add('transportationServiceFro', ChoiceType::class, [
|
||||
...$commonChoiceFieldOptions,
|
||||
'label' => 'Rückreise',
|
||||
'multiple' => false,
|
||||
'choices' => $options['selectable_transportation_services_fro'],
|
||||
]);
|
||||
}
|
||||
$form
|
||||
->add('transportationServiceTo', ChoiceType::class, [
|
||||
...$commonChoiceFieldOptions,
|
||||
'label' => 'Anreise',
|
||||
'required' => true,
|
||||
'multiple' => false,
|
||||
'choices' => $options['selectable_transportation_services_to'],
|
||||
'choice_attr' => function (?Service $service) {
|
||||
return [
|
||||
'data-booking-target' => 'field',
|
||||
'data-action' => 'select-toggle#toggle booking#toggle',
|
||||
'data-select-toggle-value' => $service->subType,
|
||||
];
|
||||
},
|
||||
])
|
||||
->add('transportationServiceFro', ChoiceType::class, [
|
||||
...$commonChoiceFieldOptions,
|
||||
'label' => 'Rückreise',
|
||||
'required' => true,
|
||||
'multiple' => false,
|
||||
'choices' => $options['selectable_transportation_services_fro'],
|
||||
])
|
||||
;
|
||||
|
||||
// Pickup
|
||||
if (true === $options['pickups_mutable']) {
|
||||
$form
|
||||
->add('pickup', ChoiceType::class, [
|
||||
'label' => 'Zustieg',
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
'choices' => $options['selectable_pickups'],
|
||||
'choice_value' => 'id',
|
||||
'choice_label' => function (?Pickup $pickup) {
|
||||
if (null === $pickup) {
|
||||
return null;
|
||||
}
|
||||
$form
|
||||
->add('pickup', ChoiceType::class, [
|
||||
'label' => 'Zustieg',
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
'choices' => $options['selectable_pickups'],
|
||||
'choice_value' => 'id',
|
||||
'choice_label' => function (?Pickup $pickup) {
|
||||
if (null === $pickup) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$price = $pickup->price;
|
||||
$price = $pickup->price;
|
||||
|
||||
if (null === $price || 0.0 === $price) {
|
||||
return $pickup->city;
|
||||
}
|
||||
if (null === $price || 0.0 === $price) {
|
||||
return $pickup->city;
|
||||
}
|
||||
|
||||
return sprintf('%s (%s €)',
|
||||
$pickup->city,
|
||||
number_format($price, 2, ',', '.')
|
||||
);
|
||||
},
|
||||
]);
|
||||
}
|
||||
return sprintf('%s (%s €)',
|
||||
$pickup->city,
|
||||
number_format($price, 2, ',', '.')
|
||||
);
|
||||
},
|
||||
])
|
||||
;
|
||||
})
|
||||
->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use ($options) {
|
||||
$data = $event->getData();
|
||||
|
||||
Reference in New Issue
Block a user