src/Form/RecaptchaType.php line 17

Open in your IDE?
  1. <?php
  2. // src/Form/Type/RecaptchaType.php
  3. namespace App\Form;
  4. use Symfony\Component\Form\AbstractType;
  5. use Karser\Recaptcha3Bundle\Form\Recaptcha3Type;
  6. use Symfony\Component\Form\FormBuilderInterface;
  7. use Symfony\Component\OptionsResolver\OptionsResolver;
  8. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  9. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  10. use Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3;
  11. // use Karser\Recaptcha3Bundle\Form\Recaptcha3Type;
  12. // use Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3;
  13. class RecaptchaType extends AbstractType
  14. {
  15.     public function buildForm(FormBuilderInterface $builder, array $options)
  16.     {
  17.         // $builder->add('recaptcha_token', HiddenType::class, [
  18.         //     'mapped' => false,
  19.         //     'attr' => [
  20.         //         'class' => 'g-recaptcha',
  21.         //         'data-sitekey' => $options['site_key'],
  22.         //         'data-callback' => 'onReCaptchaSuccess',
  23.         //     ],
  24.         // ]);
  25.         $builder->add('recaptcha_token'HiddenType::class, [
  26.             'mapped' => false,
  27.             'attr' => [
  28.                 'class' => 'g-recaptcha',
  29.                 'data-sitekey' => $options['site_key'],
  30.                 'data-callback' => 'onReCaptchaSuccess',
  31.                 
  32.             ],
  33.         ]);
  34.         // $builder->add('captcha', Recaptcha3Type::class, [
  35.         //     'constraints' => new Recaptcha3(),
  36.         //     'action_name' => 'app_forgot_password_request',
  37.         //     // 'script_nonce_csp' => $nonceCSP,
  38.         //     // 'locale' => 'fr',
  39.         // ]);
  40.     }
  41.     public function configureOptions(OptionsResolver $resolver)
  42.     {
  43.         $resolver->setDefaults([
  44.             'site_key' => null,
  45.         ]);
  46.     }
  47.     public function getBlockPrefix()
  48.     {
  49.         return 'recaptcha';
  50.     }
  51.    }