<?php
namespace App\Form\Type;
use EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType;
use EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrue;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* This class avoid repeating the same parameters for every usage of Recaptcha.
*/
class EWZRecaptchaCustomType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'mapped' => false,
'constraints' => [
new IsTrue(),
],
'attr' => [
'options' => [
// we have to define these attributes otherwise there are errors in ewz_recaptcha_widget.html.twig
'theme' => 'light',
'type' => 'image',
'size' => 'normal',
// load the scripts asynchronously
'async' => true,
'defer' => true,
],
],
]);
}
public function getParent()
{
return EWZRecaptchaType::class;
}
}