<?php
namespace App\Form;
use App\Entity\SkiClub;
use App\Entity\User;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\IsTrue;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
class RegistrationFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('firstName', TextType::class, [
'label' => 'Vorname',
])
->add('lastName', TextType::class, [
'label' => 'Nachname',
])
->add('gender', ChoiceType::class, [
'required' => true,
'multiple' => false,
'expanded' => false,
'choices' => [
'Sonstiges' => 0,
'Männlich' => 1,
'Weiblich' => 2,
],
])
->add('roles', ChoiceType::class, [
'required' => true,
'multiple' => false,
'expanded' => false,
'mapped' => false,
'choices' => [
'Standardnutzer' => 'ROLE_USER',
'Freizeitleiter' => 'ROLE_FREIZEITLEITER',
'Betreuer' => 'ROLE_BETREUER',
'Skiclub Admin' => 'ROLE_SKI_ADMIN',
'Admin' => 'ROLE_ADMIN',
],
])
->add('birthDate', TextType::class, [
'mapped' => false,
])
->add('email', TextType::class, [
'label' => 'E - Mail - Adresse',
])
->add('phoneNumber', TextType::class, [
'label' => 'Telefonnummer',
])
->add('street', TextType::class, [
'label' => 'Straße & Hausnummer',
])
->add('postCode', NumberType::class, [
'label' => 'Postleitzahl',
])
->add('city', TextType::class, [
'label' => 'Stadt',
])
->add('country', ChoiceType::class, [
'label' => 'form.registration.country',
'choices' => [
'Deutschland' => "Deutschland",
'Österreich' => 'Österreich',
'Schweiz' => 'Schweiz',
'Albanien' => 'Albanien',
'Andorra' => 'Andorra',
'Belgien' => 'Belgien',
'Bosnien und Herzegowina' => 'Bosnien und Herzegowina',
'Bulgarien' => 'Bulgarien',
'Dänemark' => 'Dänemark',
'Estland' => 'Estland',
'Finnland' => 'Finnland',
'Frankreich' => 'Frankreich',
'Griechenland' => 'Griechenland',
'Irland' => 'Irland',
'Island' => 'Island',
'Italien' => 'Italien',
'Kasachstan' => 'Kasachstan',
'Kosovo' => 'Kosovo',
'Kroatien' => 'Kroatien',
'Lettland' => 'Lettland',
'Liechtenstein' => 'Liechtenstein',
'Litauen' => 'Litauen',
'Luxemburg' => 'Luxemburg',
'Malta' => 'Malta',
'Mazedonien' => 'Mazedonien',
'Moldawien' => 'Moldawien',
'Monaco' => 'Monaco',
'Montenegro' => 'Montenegro',
'Niederlande' => 'Niederlande',
'Norwegen' => 'Norwegen',
'Polen' => 'Polen',
'Portugal' => 'Portugal',
'Rumänien' => 'Rumänien',
'Russland' => 'Russland',
'San Marino' => 'San Marino',
'Schweden' => 'Schweden',
'Serbien' => 'Serbien',
'Slowakei' => 'Slowakei',
'Slowenien' => 'Slowenien',
'Spanien' => 'Spanien',
'Tschechien' => 'Tschechien',
'Türkei' => 'Türkei',
'Ukraine' => 'Ukraine',
'Ungarn' => 'Ungarn',
'Vatikanstadt' => 'Vatikanstadt',
'Vereinigtes Königreich' => 'Vereinigtes Königreich',
'Weißrussland' => 'Weißrussland',
'andere' => "andere",
]
])
// ->add('iban', TextType::class, [
// 'label' => 'IBAN',
// 'required' => false,
// ])
// ->add('bic', TextType::class, [
// 'label' => 'BIC',
// 'required' => false,
// ])
// ->add('bank', TextType::class, [
// 'label' => 'Bank',
// 'required' => false,
// ])
// ->add('accountOwner', TextType::class, [
// 'label' => 'Kontoinhaber',
// 'required' => false,
// ])
->add('member', CheckboxType::class, [
'label' => 'Ich bin bereits Mitglied',
'mapped' => false,
'required' => false,
])
// ->add('skiClubId', EntityType::class, [
// 'class' => SkiClub::class,
// 'label' => 'Projekte :',
// 'choice_label' => 'nameandtag',
// 'attr' => [
// 'class' => 'select',
// 'data-mdb-filter' => 'true',
// ]
// ])
->add('agreeTerms', CheckboxType::class, [
'label' => 'Ich habe die Datenschutzerklärung gelesen und stimme ihr zu.*',
'mapped' => false,
'constraints' => [
new IsTrue([
'message' => 'Sie sollten unseren Bedingungen zustimmen . ',
]),
],
])
->add('plainPassword', RepeatedType::class, [
// instead of being set onto the object directly,
// this is read and encoded in the controller
// this is read and encoded in the controller
'type' => PasswordType::class,
'first_options' => array('label' => 'Passwort'),
'second_options' => array('label' => 'Passwort wiederholen'),
'mapped' => false,
'attr' => ['autocomplete' => 'new-password'],
'constraints' => [
new NotBlank([
'message' => 'Please enter a password',
]),
new Length([
'min' => 6,
'minMessage' => 'Your password should be at least {
{
limit }
} characters',
// max length allowed by Symfony for security reasons
'max' => 4096,
]),
],
])
->add('Registrieren', SubmitType::class);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => User::class,
]);
}
}