src\Form\RegisterType.php line 22

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Form;
  4. use App\Entity\User;
  5. use EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType;
  6. use EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrue as RecaptchaTrue;
  7. use Symfony\Component\Form\AbstractType;
  8. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  9. use Symfony\Component\Form\Extension\Core\Type\TextType;
  10. use Symfony\Component\Form\FormBuilderInterface;
  11. use Symfony\Component\OptionsResolver\OptionsResolver;
  12. use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
  13. use Symfony\Component\Validator\Exception\InvalidOptionsException;
  14. use Symfony\Component\Validator\Exception\MissingOptionsException;
  15. /**
  16.  * Class RegisterType.
  17.  */
  18. final class RegisterType extends AbstractType
  19. {
  20.     /**
  21.      * @throws ConstraintDefinitionException
  22.      * @throws InvalidOptionsException
  23.      * @throws MissingOptionsException
  24.      */
  25.     public function buildForm(FormBuilderInterface $builder, array $options): void
  26.     {
  27.         $builder
  28.             ->add('name'TextType::class, [
  29.                 'label' => false,
  30.                 'empty_data' => '',
  31.                 'attr' => ['class' => 'form-control r-carousel-item-control''placeholder' => 'PrĂ©nom*'],
  32.             ])
  33.             ->add('lastname'TextType::class, [
  34.                 'label' => false,
  35.                 'empty_data' => '',
  36.                 'attr' => ['class' => 'form-control r-carousel-item-control''placeholder' => 'Nom*'],
  37.             ])
  38.             ->add('email'EmailType::class, [
  39.                 'label' => false,
  40.                 'empty_data' => '',
  41.                 'attr' => ['class' => 'form-control r-carousel-item-control''placeholder' => 'Votre email*'],
  42.             ])
  43.             ->add('recaptcha'EWZRecaptchaType::class, [
  44.                 'label' => false,
  45.                 'constraints' => [new RecaptchaTrue()],
  46.                 'mapped' => false,
  47.             ])
  48.         ;
  49.     }
  50.     public function configureOptions(OptionsResolver $resolver): void
  51.     {
  52.         $resolver->setDefaults([
  53.             'data_class' => User::class,
  54.             'validation_groups' => ['register'],
  55.             'csrf_protection' => true,
  56.             'csrf_token_id' => 'security_register_item',
  57.             'csrf_field_name' => 'security_register_token',
  58.             'translation_domain' => 'user',
  59.         ]);
  60.     }
  61. }