From dfb6aec84aebae214be90014200355b334e767ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Kh=C3=BCny?= Date: Tue, 28 Nov 2023 11:32:45 +0100 Subject: [PATCH 01/14] Extend with recaptcha v3 --- DependencyInjection/Configuration.php | 1 + DependencyInjection/SuluFormExtension.php | 7 +++- Dynamic/Types/RecaptchaV3Type.php | 42 +++++++++++++++++++++++ Resources/config/type_recaptcha_v3.xml | 11 ++++++ 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 Dynamic/Types/RecaptchaV3Type.php create mode 100644 Resources/config/type_recaptcha_v3.xml diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 7275b011..05beca5d 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -145,6 +145,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->arrayNode('dynamic_disabled_types') ->prototype('scalar')->end()->defaultValue([]) ->end() + ->scalarNode('recaptcha_version')->defaultValue(2)->end() ; return $treeBuilder; diff --git a/DependencyInjection/SuluFormExtension.php b/DependencyInjection/SuluFormExtension.php index e2be7e5f..535e6be9 100644 --- a/DependencyInjection/SuluFormExtension.php +++ b/DependencyInjection/SuluFormExtension.php @@ -151,6 +151,7 @@ public function load(array $configs, ContainerBuilder $container): void $container->setParameter('sulu_form.media_collection_strategy', $mediaCollectionStrategy); $container->setParameter('sulu_form.static_forms', $config['static_forms']); $container->setParameter('sulu_form.dynamic_disabled_types', $config['dynamic_disabled_types']); + $container->setParameter('sulu_form.recaptcha.version', $config['recaptcha_version']); // Default Media Collection Strategy $container->setAlias( @@ -223,7 +224,11 @@ public function load(array $configs, ContainerBuilder $container): void } if (\class_exists(\EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType::class)) { - $loader->load('type_recaptcha.xml'); + if (3 === $container->getPArameter('sulu_form.recaptcha.version')) { + $loader->load('type_recaptcha_v3.xml'); + } else { + $loader->load('type_recaptcha.xml'); + } } if (SuluKernel::CONTEXT_WEBSITE === $container->getParameter('sulu.context')) { diff --git a/Dynamic/Types/RecaptchaV3Type.php b/Dynamic/Types/RecaptchaV3Type.php new file mode 100644 index 00000000..ac0a90cc --- /dev/null +++ b/Dynamic/Types/RecaptchaV3Type.php @@ -0,0 +1,42 @@ +add($field->getKey(), \EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaV3Type::class, $options); + } +} diff --git a/Resources/config/type_recaptcha_v3.xml b/Resources/config/type_recaptcha_v3.xml new file mode 100644 index 00000000..db059dab --- /dev/null +++ b/Resources/config/type_recaptcha_v3.xml @@ -0,0 +1,11 @@ + + + + + + + + + From 7c0dd294750ed91b005da2c57d7b289fc37f82c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Kh=C3=BCny?= Date: Tue, 28 Nov 2023 11:52:43 +0100 Subject: [PATCH 02/14] Fixed mathod --- DependencyInjection/SuluFormExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DependencyInjection/SuluFormExtension.php b/DependencyInjection/SuluFormExtension.php index 535e6be9..614c37a6 100644 --- a/DependencyInjection/SuluFormExtension.php +++ b/DependencyInjection/SuluFormExtension.php @@ -224,7 +224,7 @@ public function load(array $configs, ContainerBuilder $container): void } if (\class_exists(\EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType::class)) { - if (3 === $container->getPArameter('sulu_form.recaptcha.version')) { + if (3 === $container->getParameter('sulu_form.recaptcha.version')) { $loader->load('type_recaptcha_v3.xml'); } else { $loader->load('type_recaptcha.xml'); From 43fd65d2c2232296a76cd7ca52033dec9a48a0eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Kh=C3=BCny?= Date: Tue, 28 Nov 2023 11:54:45 +0100 Subject: [PATCH 03/14] Added v3 docu --- Resources/doc/recaptcha.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Resources/doc/recaptcha.md b/Resources/doc/recaptcha.md index 0994b667..6888ae58 100644 --- a/Resources/doc/recaptcha.md +++ b/Resources/doc/recaptcha.md @@ -30,11 +30,20 @@ EWZ\Bundle\RecaptchaBundle\EWZRecaptchaBundle::class ['all' => true], add the following config to `config/packages/ewz_recaptcha.yaml` -```yml +```yaml ewz_recaptcha: public_key: private_key: ``` +#### IMPORTANT when using RECAPTCHA v3 + +add the following config to `config/packages/sulu_form.yaml` + +```yaml +sulu_form: + recaptcha_version: 3 +``` + Visit [https://www.google.com/recaptcha/](https://www.google.com/recaptcha/intro/index.html) to get the public and private key. or visit [https://developers.google.com/recaptcha/docs/faq](https://developers.google.com/recaptcha/docs/faq) to get test keys. From b1dd0bcabf004577dfe8e88491025efaaf1eaedf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Kh=C3=BCny?= Date: Tue, 28 Nov 2023 12:56:46 +0100 Subject: [PATCH 04/14] Set recaptcha type in one file --- DependencyInjection/Configuration.php | 1 - DependencyInjection/SuluFormExtension.php | 7 +--- Dynamic/Types/RecaptchaType.php | 18 ++++++++-- Dynamic/Types/RecaptchaV3Type.php | 42 ----------------------- Resources/config/type_recaptcha.xml | 1 + 5 files changed, 18 insertions(+), 51 deletions(-) delete mode 100644 Dynamic/Types/RecaptchaV3Type.php diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 05beca5d..7275b011 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -145,7 +145,6 @@ public function getConfigTreeBuilder(): TreeBuilder ->arrayNode('dynamic_disabled_types') ->prototype('scalar')->end()->defaultValue([]) ->end() - ->scalarNode('recaptcha_version')->defaultValue(2)->end() ; return $treeBuilder; diff --git a/DependencyInjection/SuluFormExtension.php b/DependencyInjection/SuluFormExtension.php index 614c37a6..e2be7e5f 100644 --- a/DependencyInjection/SuluFormExtension.php +++ b/DependencyInjection/SuluFormExtension.php @@ -151,7 +151,6 @@ public function load(array $configs, ContainerBuilder $container): void $container->setParameter('sulu_form.media_collection_strategy', $mediaCollectionStrategy); $container->setParameter('sulu_form.static_forms', $config['static_forms']); $container->setParameter('sulu_form.dynamic_disabled_types', $config['dynamic_disabled_types']); - $container->setParameter('sulu_form.recaptcha.version', $config['recaptcha_version']); // Default Media Collection Strategy $container->setAlias( @@ -224,11 +223,7 @@ public function load(array $configs, ContainerBuilder $container): void } if (\class_exists(\EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType::class)) { - if (3 === $container->getParameter('sulu_form.recaptcha.version')) { - $loader->load('type_recaptcha_v3.xml'); - } else { - $loader->load('type_recaptcha.xml'); - } + $loader->load('type_recaptcha.xml'); } if (SuluKernel::CONTEXT_WEBSITE === $container->getParameter('sulu.context')) { diff --git a/Dynamic/Types/RecaptchaType.php b/Dynamic/Types/RecaptchaType.php index fd5af178..55a3bfc3 100644 --- a/Dynamic/Types/RecaptchaType.php +++ b/Dynamic/Types/RecaptchaType.php @@ -23,6 +23,11 @@ class RecaptchaType implements FormFieldTypeInterface { use SimpleTypeTrait; + public function __construct( + private readonly int $recaptchaVersion + ) { + } + public function getConfiguration(): FormFieldTypeConfiguration { return new FormFieldTypeConfiguration( @@ -35,13 +40,22 @@ public function getConfiguration(): FormFieldTypeConfiguration public function build(FormBuilderInterface $builder, FormField $field, string $locale, array $options): void { // Use in this way the recaptcha bundle could maybe not exists. + $constraint = new \EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrue(); + $type = \EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType::class; + + if (3 == $this->recaptchaVersion) { + $constraint = new \EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrueV3(); + $type = \EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaV3Type::class; + } + $options['mapped'] = false; - $options['constraints'] = new \EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrue(); + $options['constraints'] = $constraint; $options['attr']['options'] = [ 'theme' => 'light', 'type' => 'image', 'size' => 'normal', ]; - $builder->add($field->getKey(), \EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType::class, $options); + + $builder->add($field->getKey(), $type, $options); } } diff --git a/Dynamic/Types/RecaptchaV3Type.php b/Dynamic/Types/RecaptchaV3Type.php deleted file mode 100644 index ac0a90cc..00000000 --- a/Dynamic/Types/RecaptchaV3Type.php +++ /dev/null @@ -1,42 +0,0 @@ -add($field->getKey(), \EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaV3Type::class, $options); - } -} diff --git a/Resources/config/type_recaptcha.xml b/Resources/config/type_recaptcha.xml index 09112939..c203ed82 100644 --- a/Resources/config/type_recaptcha.xml +++ b/Resources/config/type_recaptcha.xml @@ -5,6 +5,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> + %ewz_recaptcha.version% From 13129e1a551a3a29c569a74de7e3bab3780d8267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Kh=C3=BCny?= Date: Tue, 28 Nov 2023 12:58:21 +0100 Subject: [PATCH 05/14] remove unecassary files --- Resources/config/type_recaptcha_v3.xml | 11 ----------- Resources/doc/recaptcha.md | 9 --------- 2 files changed, 20 deletions(-) delete mode 100644 Resources/config/type_recaptcha_v3.xml diff --git a/Resources/config/type_recaptcha_v3.xml b/Resources/config/type_recaptcha_v3.xml deleted file mode 100644 index db059dab..00000000 --- a/Resources/config/type_recaptcha_v3.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - diff --git a/Resources/doc/recaptcha.md b/Resources/doc/recaptcha.md index 6888ae58..5fdb3ed0 100644 --- a/Resources/doc/recaptcha.md +++ b/Resources/doc/recaptcha.md @@ -36,14 +36,5 @@ ewz_recaptcha: private_key: ``` -#### IMPORTANT when using RECAPTCHA v3 - -add the following config to `config/packages/sulu_form.yaml` - -```yaml -sulu_form: - recaptcha_version: 3 -``` - Visit [https://www.google.com/recaptcha/](https://www.google.com/recaptcha/intro/index.html) to get the public and private key. or visit [https://developers.google.com/recaptcha/docs/faq](https://developers.google.com/recaptcha/docs/faq) to get test keys. From 5c680997111748f23e8e2c5f9d547e653b0941f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Kh=C3=BCny?= Date: Tue, 28 Nov 2023 13:07:17 +0100 Subject: [PATCH 06/14] Fixed default value --- Dynamic/Types/RecaptchaType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dynamic/Types/RecaptchaType.php b/Dynamic/Types/RecaptchaType.php index 55a3bfc3..97026b3e 100644 --- a/Dynamic/Types/RecaptchaType.php +++ b/Dynamic/Types/RecaptchaType.php @@ -24,7 +24,7 @@ class RecaptchaType implements FormFieldTypeInterface use SimpleTypeTrait; public function __construct( - private readonly int $recaptchaVersion + private readonly int $recaptchaVersion = 2 ) { } From 56d955ce866a847a440eb2807cf5923699834952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Kh=C3=BCny?= Date: Tue, 28 Nov 2023 13:10:05 +0100 Subject: [PATCH 07/14] ignore argument --- Resources/config/type_recaptcha.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/type_recaptcha.xml b/Resources/config/type_recaptcha.xml index c203ed82..971dfb41 100644 --- a/Resources/config/type_recaptcha.xml +++ b/Resources/config/type_recaptcha.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - %ewz_recaptcha.version% + %ewz_recaptcha.version% From b0ceb7e5d981f5b1996704238d859a38bc4e8828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Kh=C3=BCny?= Date: Tue, 28 Nov 2023 13:20:53 +0100 Subject: [PATCH 08/14] Fixed service --- Resources/config/type_recaptcha.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/type_recaptcha.xml b/Resources/config/type_recaptcha.xml index 971dfb41..6b09b817 100644 --- a/Resources/config/type_recaptcha.xml +++ b/Resources/config/type_recaptcha.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - %ewz_recaptcha.version% + %ewz_recaptcha.version% From 9a3766ab150ea4f42fbb09af6ef593b97a0bdc0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Kh=C3=BCny?= Date: Tue, 28 Nov 2023 13:31:18 +0100 Subject: [PATCH 09/14] Fixed possible argument --- Dynamic/Types/RecaptchaType.php | 5 +++-- Resources/config/type_recaptcha.xml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Dynamic/Types/RecaptchaType.php b/Dynamic/Types/RecaptchaType.php index 97026b3e..7556e482 100644 --- a/Dynamic/Types/RecaptchaType.php +++ b/Dynamic/Types/RecaptchaType.php @@ -14,6 +14,7 @@ use Sulu\Bundle\FormBundle\Dynamic\FormFieldTypeConfiguration; use Sulu\Bundle\FormBundle\Dynamic\FormFieldTypeInterface; use Sulu\Bundle\FormBundle\Entity\FormField; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Form\FormBuilderInterface; /** @@ -24,7 +25,7 @@ class RecaptchaType implements FormFieldTypeInterface use SimpleTypeTrait; public function __construct( - private readonly int $recaptchaVersion = 2 + private readonly ParameterBagInterface $params ) { } @@ -43,7 +44,7 @@ public function build(FormBuilderInterface $builder, FormField $field, string $l $constraint = new \EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrue(); $type = \EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType::class; - if (3 == $this->recaptchaVersion) { + if ($this->params->has('ewz_recaptcha.version') && 3 == $this->params->get('ewz_recaptcha.version')) { $constraint = new \EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrueV3(); $type = \EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaV3Type::class; } diff --git a/Resources/config/type_recaptcha.xml b/Resources/config/type_recaptcha.xml index 6b09b817..d452aca3 100644 --- a/Resources/config/type_recaptcha.xml +++ b/Resources/config/type_recaptcha.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - %ewz_recaptcha.version% + From 97a16ea80bde57b7666cfcff9c0aaadcc696ae16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Kh=C3=BCny?= Date: Tue, 28 Nov 2023 13:35:42 +0100 Subject: [PATCH 10/14] Fixed parameter bag --- Dynamic/Types/RecaptchaType.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Dynamic/Types/RecaptchaType.php b/Dynamic/Types/RecaptchaType.php index 7556e482..2be0f3b1 100644 --- a/Dynamic/Types/RecaptchaType.php +++ b/Dynamic/Types/RecaptchaType.php @@ -25,7 +25,7 @@ class RecaptchaType implements FormFieldTypeInterface use SimpleTypeTrait; public function __construct( - private readonly ParameterBagInterface $params + private readonly ?ParameterBagInterface $params = null ) { } @@ -44,7 +44,10 @@ public function build(FormBuilderInterface $builder, FormField $field, string $l $constraint = new \EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrue(); $type = \EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType::class; - if ($this->params->has('ewz_recaptcha.version') && 3 == $this->params->get('ewz_recaptcha.version')) { + if ($this->params + && $this->params->has('ewz_recaptcha.version') + && 3 == $this->params->get('ewz_recaptcha.version') + ) { $constraint = new \EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrueV3(); $type = \EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaV3Type::class; } From 7b0fb106919b93e5d223a4e8fac6a9b9b4b4e4d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Kh=C3=BCny?= Date: Tue, 28 Nov 2023 13:39:45 +0100 Subject: [PATCH 11/14] Fixed recaptcha type --- Dynamic/Types/RecaptchaType.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Dynamic/Types/RecaptchaType.php b/Dynamic/Types/RecaptchaType.php index 2be0f3b1..4bfbcbde 100644 --- a/Dynamic/Types/RecaptchaType.php +++ b/Dynamic/Types/RecaptchaType.php @@ -24,9 +24,12 @@ class RecaptchaType implements FormFieldTypeInterface { use SimpleTypeTrait; + private ParameterBagInterface $params; + public function __construct( - private readonly ?ParameterBagInterface $params = null + ParameterBagInterface $params ) { + $this->params = $params; } public function getConfiguration(): FormFieldTypeConfiguration @@ -44,8 +47,7 @@ public function build(FormBuilderInterface $builder, FormField $field, string $l $constraint = new \EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrue(); $type = \EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType::class; - if ($this->params - && $this->params->has('ewz_recaptcha.version') + if ($this->params->has('ewz_recaptcha.version') && 3 == $this->params->get('ewz_recaptcha.version') ) { $constraint = new \EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrueV3(); From 660875d326b8997af680d10e6d3bca5eb578a102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Kh=C3=BCny?= Date: Tue, 28 Nov 2023 13:42:13 +0100 Subject: [PATCH 12/14] Fixed php version --- Dynamic/Types/RecaptchaType.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Dynamic/Types/RecaptchaType.php b/Dynamic/Types/RecaptchaType.php index 4bfbcbde..d9ef736b 100644 --- a/Dynamic/Types/RecaptchaType.php +++ b/Dynamic/Types/RecaptchaType.php @@ -24,11 +24,15 @@ class RecaptchaType implements FormFieldTypeInterface { use SimpleTypeTrait; - private ParameterBagInterface $params; + /** + * @var ParameterBagInterface + */ + private $params; - public function __construct( - ParameterBagInterface $params - ) { + /** + * @param ParameterBagInterface $params + */ + public function __construct($params) { $this->params = $params; } From 3f73c40dde0540ed1b4871c6fbb34157e96fcbfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Kh=C3=BCny?= Date: Wed, 29 Nov 2023 11:38:31 +0100 Subject: [PATCH 13/14] Fix recaptcha attr --- Dynamic/Types/RecaptchaType.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Dynamic/Types/RecaptchaType.php b/Dynamic/Types/RecaptchaType.php index d9ef736b..e5afd55e 100644 --- a/Dynamic/Types/RecaptchaType.php +++ b/Dynamic/Types/RecaptchaType.php @@ -32,7 +32,8 @@ class RecaptchaType implements FormFieldTypeInterface /** * @param ParameterBagInterface $params */ - public function __construct($params) { + public function __construct($params) + { $this->params = $params; } @@ -50,14 +51,6 @@ public function build(FormBuilderInterface $builder, FormField $field, string $l // Use in this way the recaptcha bundle could maybe not exists. $constraint = new \EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrue(); $type = \EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType::class; - - if ($this->params->has('ewz_recaptcha.version') - && 3 == $this->params->get('ewz_recaptcha.version') - ) { - $constraint = new \EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrueV3(); - $type = \EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaV3Type::class; - } - $options['mapped'] = false; $options['constraints'] = $constraint; $options['attr']['options'] = [ @@ -66,6 +59,14 @@ public function build(FormBuilderInterface $builder, FormField $field, string $l 'size' => 'normal', ]; + if ($this->params->has('ewz_recaptcha.version') + && 3 == $this->params->get('ewz_recaptcha.version') + ) { + $constraint = new \EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrueV3(); + $type = \EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaV3Type::class; + unset($options['attr']); + } + $builder->add($field->getKey(), $type, $options); } } From a0cc6c069e2500026ab07f643960ab1293998972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Kh=C3=BCny?= Date: Wed, 29 Nov 2023 13:41:07 +0100 Subject: [PATCH 14/14] Fixed contraint --- Dynamic/Types/RecaptchaType.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dynamic/Types/RecaptchaType.php b/Dynamic/Types/RecaptchaType.php index e5afd55e..d529c250 100644 --- a/Dynamic/Types/RecaptchaType.php +++ b/Dynamic/Types/RecaptchaType.php @@ -52,7 +52,6 @@ public function build(FormBuilderInterface $builder, FormField $field, string $l $constraint = new \EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrue(); $type = \EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType::class; $options['mapped'] = false; - $options['constraints'] = $constraint; $options['attr']['options'] = [ 'theme' => 'light', 'type' => 'image', @@ -66,6 +65,8 @@ public function build(FormBuilderInterface $builder, FormField $field, string $l $type = \EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaV3Type::class; unset($options['attr']); } + + $options['constraints'] = $constraint; $builder->add($field->getKey(), $type, $options); }