src/Form/NewsletterType.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Newsletter;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  6. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  7. use Symfony\Component\Form\Extension\Core\Type\TextType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. use Karser\Recaptcha3Bundle\Form\Recaptcha3Type;
  11. use Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3;
  12. class NewsletterType extends AbstractType
  13. {
  14.     public function buildForm(FormBuilderInterface $builder, array $options)
  15.     {
  16.         $builder
  17.             ->add('name'TextType::class, [
  18.                 'label' => false,
  19.                 'attr' => [
  20.                     'class' => 'form-control white',
  21.                     'placeholder' => 'Nom Prénom',
  22.                     ],
  23.             ])
  24.             ->add('email'EmailType::class, [
  25.                 'label' => 'Email',
  26.                 'attr' => [
  27.                     'class' => 'form-control white',
  28.                     'placeholder' => 'Email',
  29.                     ],
  30.             ])
  31.             ->add('privacyPolicy'CheckboxType::class, [
  32.                 'label' => 'J\'accepte la <a href="' $options['confidentiality_path'] . '">politique de confidentialité</a>',
  33.                 'label_html' => true,
  34.                 'required' => true,
  35.                 'mapped' => false,
  36.             ])
  37.             ->add('captcha'Recaptcha3Type::class, [
  38.                 'constraints' => new Recaptcha3(),
  39.                 'action_name' => 'newsletter'// Nom de l'action pour le reCAPTCHA
  40.             ]);
  41.     }
  42.     public function configureOptions(OptionsResolver $resolver)
  43.     {
  44.         $resolver->setDefaults([
  45.             'confidentiality_path' => '',
  46.             'data_class' => Newsletter::class,
  47.         ]);
  48.     }
  49. }