src/Form/RegistrationFormType.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\User;
  4. use Symfony\Component\DependencyInjection\Container;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  7. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. use Symfony\Component\Validator\Constraints\IsTrue;
  11. use Symfony\Component\Validator\Constraints\Length;
  12. use Symfony\Component\Validator\Constraints\NotBlank;
  13. use Symfony\Component\Form\Extension\Core\Type\TextType;
  14. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  15. use Symfony\Component\Form\Extension\Core\Type\DateType;
  16. use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  17. use Symfony\Component\Form\Extension\Core\Type\TelType;
  18. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  19. use Symfony\Component\Form\Extension\Core\Type\CountryType;
  20. use Symfony\Component\Form\Extension\Core\Type\BirthdayType;
  21. class RegistrationFormType extends AbstractType
  22. {
  23.     public function buildForm(FormBuilderInterface $builder, array $options)
  24.     {
  25.         $builder
  26.         ->add('name'TextType::class,[
  27.             'required'=>true,
  28.             'attr'=>[
  29.                 'class'=>'form-control col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 mb-1'
  30.             ],
  31.             'label_attr'=>[
  32.                 'class'=>'form-label col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 text-left fontSize mb-0'
  33.             ],
  34.             'label'=>'Nom',
  35.         ])
  36.         ->add('firstname'TextType::class,[
  37.             'required'=>true,
  38.             'attr'=>[
  39.                 'class'=>'form-control col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 mb-1'
  40.             ],
  41.             'label_attr'=>[
  42.                 'class'=>'form-label col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 text-left fontSize mb-0'
  43.             ],
  44.             'label'=>'Prenom',
  45.         ])
  46.         ->add('birthday'BirthdayType::class,[
  47.             'required'=>true,
  48.             'attr'=>[
  49.                 'class'=>'mb-1'
  50.             ],
  51.             'label'=>'Date de naissance',
  52.             'label_attr'=>[
  53.                 'class'=>'form-label col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 text-left fontSize mb-0'
  54.             ],
  55.         ])
  56.         ->add('adress'TextType::class,[
  57.             'required'=>true,
  58.             'attr'=>[
  59.                 'class'=>'form-control col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 mb-1'
  60.             ],
  61.             'label_attr'=>[
  62.                 'class'=>'form-label col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 text-left fontSize mb-0'
  63.             ],
  64.             'label'=>'Adresse',
  65.         ])
  66.         ->add('postalCode'IntegerType::class,[
  67.             'required'=>true,
  68.             'attr'=>[
  69.                 'class'=>'form-control col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 mb-1'
  70.             ],
  71.             'label_attr'=>[
  72.                 'class'=>'form-label col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 text-left fontSize mb-0'
  73.             ],
  74.             'label'=>'Code postal',
  75.         ])
  76.         ->add('city'TextType::class,[
  77.             'required'=>true,
  78.             'attr'=>[
  79.                 'class'=>'form-control col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 mb-1'
  80.             ],
  81.             'label_attr'=>[
  82.                 'class'=>'form-label col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 text-left fontSize mb-0'
  83.             ],
  84.             'label'=>'ville',
  85.         ])
  86.         ->add('country'CountryType::class,[
  87.             'required'=>true,
  88.             'attr'=>[
  89.                 'class'=>'form-control col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 mb-1'
  90.             ],
  91.             'label_attr'=>[
  92.                 'class'=>'form-label col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 text-left fontSize mb-0'
  93.             ],
  94.             'label'=>'Pays',
  95.         ])
  96.         ->add('phone'TelType::class,[
  97.             'required'=>true,
  98.             'attr'=>[
  99.                 'class'=>'form-control col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 mb-1'
  100.             ],
  101.             'label_attr'=>[
  102.                 'class'=>'form-label col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 text-left fontSize mb-0'
  103.             ],
  104.             'label'=>'Telephone',
  105.         ])
  106.         ->add('email'EmailType::class,[
  107.             'required'=>true,
  108.             'attr'=>[
  109.                 'class'=>'form-control col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 mb-1'
  110.             ],
  111.             'label_attr'=>[
  112.                 'class'=>'form-label col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 text-left fontSize mb-0'
  113.             ],
  114.             'label'=>'Email',
  115.         ])
  116.         ->add('pseudonym'TextType::class,[
  117.             'required'=>true,
  118.             'attr'=>[
  119.                 'class'=>'form-control col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 mb-1'
  120.             ],
  121.             'label_attr'=>[
  122.                 'class'=>'form-label col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 text-left fontSize mb-0'
  123.             ],
  124.             'label'=>'Pseudo',
  125.         ])
  126.         ->add('plainPassword'PasswordType::class, [
  127.             // instead of being set onto the object directly,
  128.             // this is read and encoded in the controller
  129.             'mapped' => false,
  130.             'constraints' => [
  131.                 new NotBlank([
  132.                     'message' => 'Please enter a password',
  133.                 ]),
  134.                 new Length([
  135.                     'min' => 6,
  136.                     'minMessage' => 'Your password should be at least {{ limit }} characters',
  137.                     // max length allowed by Symfony for security reasons
  138.                     'max' => 4096,
  139.                 ]),
  140.             ],
  141.             'required'=>true,
  142.             'attr'=>[
  143.                 'class'=>'form-control col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 mb-1'
  144.             ],
  145.             'label_attr'=>[
  146.                 'class'=>'form-label col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 text-left fontSize mb-0'
  147.             ],
  148.             'label'=>'Mot de passe',
  149.         ])
  150.         ->add('agreeTerms'CheckboxType::class, [
  151.             'mapped' => false,
  152.             'constraints' => [
  153.                 new IsTrue([
  154.                     'message' => "Vous devez accepter les conditions générales d'utilisation.",
  155.                 ]),
  156.             ],
  157.             'label'=> "J'accepte",
  158.             'label_attr'=>[
  159.                 'class' => 'form-label col-xl-11 col-lg-11 col-md-11 col-sm-11 col-11 text-center align-self-center',
  160.             ],
  161.             'attr'=>[
  162.                 'class'=>'form-check col-xl-1 col-lg-1 col-md-1 col-sm-1 col-1 align-self-center mb-1'
  163.             ],
  164.         ])
  165.             
  166.          ;
  167.     }
  168.     public function configureOptions(OptionsResolver $resolver)
  169.     {
  170.         $resolver->setDefaults([
  171.             'data_class' => User::class,
  172.         ]);
  173.     }
  174. }