src/Form/RegistrationFormType.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\SkiClub;
  4. use App\Entity\User;
  5. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  6. use Symfony\Component\Form\AbstractType;
  7. use Symfony\Component\Form\CallbackTransformer;
  8. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  9. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  10. use Symfony\Component\Form\Extension\Core\Type\DateType;
  11. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  12. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  13. use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
  14. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  15. use Symfony\Component\Form\Extension\Core\Type\TextType;
  16. use Symfony\Component\Form\FormBuilderInterface;
  17. use Symfony\Component\OptionsResolver\OptionsResolver;
  18. use Symfony\Component\Validator\Constraints\IsTrue;
  19. use Symfony\Component\Validator\Constraints\Length;
  20. use Symfony\Component\Validator\Constraints\NotBlank;
  21. class RegistrationFormType extends AbstractType
  22. {
  23.     public function buildForm(FormBuilderInterface $builder, array $options): void
  24.     {
  25.         $builder
  26.             ->add('firstName'TextType::class, [
  27.                 'label' => 'Vorname',
  28.             ])
  29.             ->add('lastName'TextType::class, [
  30.                 'label' => 'Nachname',
  31.             ])
  32.             ->add('gender'ChoiceType::class, [
  33.                 'required' => true,
  34.                 'multiple' => false,
  35.                 'expanded' => false,
  36.                 'choices' => [
  37.                     'Sonstiges' => 0,
  38.                     'Männlich' => 1,
  39.                     'Weiblich' => 2,
  40.                 ],
  41.             ])
  42.             ->add('roles'ChoiceType::class, [
  43.                 'required' => true,
  44.                 'multiple' => false,
  45.                 'expanded' => false,
  46.                 'mapped' => false,
  47.                 'choices' => [
  48.                     'Standardnutzer' => 'ROLE_USER',
  49.                     'Freizeitleiter' => 'ROLE_FREIZEITLEITER',
  50.                     'Betreuer' => 'ROLE_BETREUER',
  51.                     'Skiclub Admin' => 'ROLE_SKI_ADMIN',
  52.                     'Admin' => 'ROLE_ADMIN',
  53.                 ],
  54.             ])
  55.             ->add('birthDate'TextType::class, [
  56.                 'mapped' => false,
  57.             ])
  58.             ->add('email'TextType::class, [
  59.                 'label' => 'E - Mail - Adresse',
  60.             ])
  61.             ->add('phoneNumber'TextType::class, [
  62.                 'label' => 'Telefonnummer',
  63.             ])
  64.             ->add('street'TextType::class, [
  65.                 'label' => 'Straße & Hausnummer',
  66.             ])
  67.             ->add('postCode'NumberType::class, [
  68.                 'label' => 'Postleitzahl',
  69.             ])
  70.             ->add('city'TextType::class, [
  71.                 'label' => 'Stadt',
  72.             ])
  73.             ->add('country'ChoiceType::class, [
  74.                 'label' => 'form.registration.country',
  75.                 'choices' => [
  76.                     'Deutschland' => "Deutschland",
  77.                     'Österreich' => 'Österreich',
  78.                     'Schweiz' => 'Schweiz',
  79.                     'Albanien' => 'Albanien',
  80.                     'Andorra' => 'Andorra',
  81.                     'Belgien' => 'Belgien',
  82.                     'Bosnien und Herzegowina' => 'Bosnien und Herzegowina',
  83.                     'Bulgarien' => 'Bulgarien',
  84.                     'Dänemark' => 'Dänemark',
  85.                     'Estland' => 'Estland',
  86.                     'Finnland' => 'Finnland',
  87.                     'Frankreich' => 'Frankreich',
  88.                     'Griechenland' => 'Griechenland',
  89.                     'Irland' => 'Irland',
  90.                     'Island' => 'Island',
  91.                     'Italien' => 'Italien',
  92.                     'Kasachstan' => 'Kasachstan',
  93.                     'Kosovo' => 'Kosovo',
  94.                     'Kroatien' => 'Kroatien',
  95.                     'Lettland' => 'Lettland',
  96.                     'Liechtenstein' => 'Liechtenstein',
  97.                     'Litauen' => 'Litauen',
  98.                     'Luxemburg' => 'Luxemburg',
  99.                     'Malta' => 'Malta',
  100.                     'Mazedonien' => 'Mazedonien',
  101.                     'Moldawien' => 'Moldawien',
  102.                     'Monaco' => 'Monaco',
  103.                     'Montenegro' => 'Montenegro',
  104.                     'Niederlande' => 'Niederlande',
  105.                     'Norwegen' => 'Norwegen',
  106.                     'Polen' => 'Polen',
  107.                     'Portugal' => 'Portugal',
  108.                     'Rumänien' => 'Rumänien',
  109.                     'Russland' => 'Russland',
  110.                     'San Marino' => 'San Marino',
  111.                     'Schweden' => 'Schweden',
  112.                     'Serbien' => 'Serbien',
  113.                     'Slowakei' => 'Slowakei',
  114.                     'Slowenien' => 'Slowenien',
  115.                     'Spanien' => 'Spanien',
  116.                     'Tschechien' => 'Tschechien',
  117.                     'Türkei' => 'Türkei',
  118.                     'Ukraine' => 'Ukraine',
  119.                     'Ungarn' => 'Ungarn',
  120.                     'Vatikanstadt' => 'Vatikanstadt',
  121.                     'Vereinigtes Königreich' => 'Vereinigtes Königreich',
  122.                     'Weißrussland' => 'Weißrussland',
  123.                     'andere' => "andere",
  124.                 ]
  125.             ])
  126. //            ->add('iban', TextType::class, [
  127. //                'label' => 'IBAN',
  128. //                'required' => false,
  129. //            ])
  130. //            ->add('bic', TextType::class, [
  131. //                'label' => 'BIC',
  132. //                'required' => false,
  133. //            ])
  134. //            ->add('bank', TextType::class, [
  135. //                'label' => 'Bank',
  136. //                'required' => false,
  137. //            ])
  138. //            ->add('accountOwner', TextType::class, [
  139. //                'label' => 'Kontoinhaber',
  140. //                'required' => false,
  141. //            ])
  142.             ->add('member'CheckboxType::class, [
  143.                 'label' => 'Ich bin bereits Mitglied',
  144.                 'mapped' => false,
  145.                 'required' => false,
  146.             ])
  147. //            ->add('skiClubId', EntityType::class, [
  148. //                'class' => SkiClub::class,
  149. //                'label' => 'Projekte :',
  150. //                'choice_label' => 'nameandtag',
  151. //                'attr' => [
  152. //                    'class' => 'select',
  153. //                    'data-mdb-filter' => 'true',
  154. //                ]
  155. //            ])
  156.             ->add('agreeTerms'CheckboxType::class, [
  157.                 'label' => 'Ich habe die Datenschutzerklärung gelesen und stimme ihr zu.*',
  158.                 'mapped' => false,
  159.                 'constraints' => [
  160.                     new IsTrue([
  161.                         'message' => 'Sie sollten unseren Bedingungen zustimmen . ',
  162.                     ]),
  163.                 ],
  164.             ])
  165.             ->add('plainPassword'RepeatedType::class, [
  166.                 // instead of being set onto the object directly,
  167.                 // this is read and encoded in the controller
  168.                 // this is read and encoded in the controller
  169.                 'type' => PasswordType::class,
  170.                 'first_options' => array('label' => 'Passwort'),
  171.                 'second_options' => array('label' => 'Passwort wiederholen'),
  172.                 'mapped' => false,
  173.                 'attr' => ['autocomplete' => 'new-password'],
  174.                 'constraints' => [
  175.                     new NotBlank([
  176.                         'message' => 'Please enter a password',
  177.                     ]),
  178.                     new Length([
  179.                         'min' => 6,
  180.                         'minMessage' => 'Your password should be at least {
  181.         {
  182.             limit }
  183.     } characters',
  184.                         // max length allowed by Symfony for security reasons
  185.                         'max' => 4096,
  186.                     ]),
  187.                 ],
  188.             ])
  189.             ->add('Registrieren'SubmitType::class);
  190.     }
  191.     public function configureOptions(OptionsResolver $resolver): void
  192.     {
  193.         $resolver->setDefaults([
  194.             'data_class' => User::class,
  195.         ]);
  196.     }
  197. }