]> Raphaël G. Git Repositories - packbundle/commitdiff
Allow captcha to be enabled in form service definition
authorRaphaël Gertz <git@rapsys.eu>
Tue, 14 Oct 2025 10:43:15 +0000 (12:43 +0200)
committerRaphaël Gertz <git@rapsys.eu>
Tue, 14 Oct 2025 10:43:15 +0000 (12:43 +0200)
Form/CaptchaType.php

index f8cf3d024deba7465841d157d49a34981c7947e4..8b0a872654ca6632948307ea80008540393ac539 100644 (file)
@@ -37,8 +37,9 @@ class CaptchaType extends AbstractType {
         * @param ?ImageUtil $image The image instance
         * @param ?SluggerUtil $slugger The slugger instance
         * @param ?TranslatorInterface $translator The translator instance
+        * @param bool $enable Use captcha
         */
-       public function __construct(protected ?ImageUtil $image = null, protected ?SluggerUtil $slugger = null, protected ?TranslatorInterface $translator = null) {
+       public function __construct(protected ?ImageUtil $image = null, protected ?SluggerUtil $slugger = null, protected ?TranslatorInterface $translator = null, protected bool $enable = false) {
        }
 
        /**
@@ -71,7 +72,7 @@ class CaptchaType extends AbstractType {
                parent::configureOptions($resolver);
 
                //Set defaults
-               $resolver->setDefaults(['captcha' => false, 'error_bubbling' => true, 'translation_domain' => RapsysPackBundle::getAlias()]);
+               $resolver->setDefaults(['captcha' => $this->enable, 'error_bubbling' => true, 'translation_domain' => RapsysPackBundle::getAlias()]);
 
                //Add extra captcha option
                $resolver->setAllowedTypes('captcha', 'boolean');