src/Form/RegistrationFormType.php line 21

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\EmailType;
  6. use Symfony\Component\Form\Extension\Core\Type\TextType;
  7. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  8. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  9. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  10. use Symfony\Component\Form\FormBuilderInterface;
  11. use Symfony\Component\OptionsResolver\OptionsResolver;
  12. use Symfony\Component\Validator\Constraints\Email;
  13. use Symfony\Component\Validator\Constraints\IsTrue;
  14. use Symfony\Component\Validator\Constraints\Length;
  15. use Symfony\Component\Validator\Constraints\NotBlank;
  16. //use VictorPrdh\RecaptchaBundle\Form\ReCaptchaType;
  17. use Gregwar\CaptchaBundle\Type\CaptchaType;
  18. class RegistrationFormType extends AbstractType
  19. {
  20.     public function buildForm(FormBuilderInterface $builder, array $options): void
  21.     {
  22.         $builder
  23.             ->add('email'EmailType::class, [
  24.                 'constraints' => [
  25.                     new Email(),
  26.                     new NotBlank(),
  27.                 ],
  28.                 'label' => false,
  29.                 'attr' => [
  30.                     'placeholder' => 'Adresse mail'
  31.                 ]
  32.             ])
  33.             ->add('username'TextType::class, [
  34.                 'label' => false,
  35.                 'attr' => [
  36.                     'placeholder' => 'Utilisateur'
  37.                 ]
  38.             ])
  39.             ->add('plainPassword'PasswordType::class, [
  40.                 // instead of being set onto the object directly,
  41.                 // this is read and encoded in the controller
  42.                 'mapped' => false,
  43.                 'label' => false,
  44.                 'attr' => [
  45.                     'autocomplete' => 'new-password',
  46.                     'placeholder' => 'Mot de passe'
  47.                 ],
  48.                 'constraints' => [
  49.                     new NotBlank([
  50.                         'message' => 'Please enter a password',
  51.                     ]),
  52.                     new Length([
  53.                         'min' => 6,
  54.                         'minMessage' => 'Your password should be at least {{ limit }} characters',
  55.                         // max length allowed by Symfony for security reasons
  56.                         'max' => 4096,
  57.                     ]),
  58.                 ],
  59.             ])
  60.             ->add('plainPasswordConfirm'PasswordType::class, [
  61.                 // instead of being set onto the object directly,
  62.                 // this is read and encoded in the controller
  63.                 'mapped' => false,
  64.                 'label' => false,
  65.                 'attr' => [
  66.                     'autocomplete' => 'new-password-confirm',
  67.                     'placeholder' => 'Confirmer mot de passe'
  68.                 ],
  69.                 'constraints' => [
  70.                     new NotBlank([
  71.                         'message' => 'Please enter a password',
  72.                     ]),
  73.                     new Length([
  74.                         'min' => 6,
  75.                         'minMessage' => 'Your password should be at least {{ limit }} characters',
  76.                         // max length allowed by Symfony for security reasons
  77.                         'max' => 4096,
  78.                     ]),
  79.                 ],
  80.             ])
  81.             /*->add('recaptcha', ReCaptchaType::class)
  82.             ->add('save', SubmitType::class, [
  83.                 'label' => false,
  84.             ])*/
  85.             ->add('captcha'CaptchaType::class, array(
  86.                 'width' => 200,
  87.                 'height' => 50,
  88.                 'length' => 6,
  89.             ))
  90.              ->add('save'SubmitType::class, [
  91.                 'label' => false,
  92.             ])
  93.         ;
  94.     }
  95.     public function configureOptions(OptionsResolver $resolver): void
  96.     {
  97.         $resolver->setDefaults([
  98.             'data_class' => User::class,
  99.         ]);
  100.     }
  101.     
  102. }