src/Form/RegistrationFormType.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\User;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  6. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  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. class RegistrationFormType extends AbstractType
  14. {
  15.     public function buildForm(FormBuilderInterface $builder, array $options): void
  16.     {
  17.         $builder
  18.             ->add('adresse')
  19.             ->add('nom')
  20.             ->add('prenom')
  21.             ->add('phone')
  22.             ->add('email')
  23.             ->add('options'ChoiceType::class, [
  24.                 'choices' => [
  25.                     'Student' => 'Student',
  26.                     'Goach' => 'Goach',
  27.                     'Partner' => 'Partner',
  28.                 ],
  29.                 'expanded' => true,
  30.                 'multiple' => false,
  31.                 'label' => 'Sélectionnez une option:',
  32.             ])
  33. //            ->add('agreeTerms', CheckboxType::class, [
  34. //                'mapped' => false,
  35. //                'constraints' => [
  36. //                    new IsTrue([
  37. //                        'message' => 'You should agree to our terms.',
  38. //                    ]),
  39. //                ],
  40. //            ])
  41.             ->add('plainPassword'PasswordType::class, [
  42.                 // instead of being set onto the object directly,
  43.                 // this is read and encoded in the controller
  44.                 'mapped' => false,
  45.                 'attr' => ['autocomplete' => 'new-password'],
  46.                 'constraints' => [
  47.                     new NotBlank([
  48.                         'message' => 'Please enter a password',
  49.                     ]),
  50.                     new Length([
  51.                         'min' => 6,
  52.                         'minMessage' => 'Your password should be at least {{ limit }} characters',
  53.                         // max length allowed by Symfony for security reasons
  54.                         'max' => 4096,
  55.                     ]),
  56.                 ],
  57.             ])
  58.         ;
  59.     }
  60.     public function configureOptions(OptionsResolver $resolver): void
  61.     {
  62.         $resolver->setDefaults([
  63.             'data_class' => User::class,
  64.         ]);
  65.     }
  66. }