EWZRecaptchaBundle
EWZRecaptchaBundle copied to clipboard
[Symfony 4.3.5] Twig failed to render the widget "Array to string conversion"
Hi!
I'm trying to install this bundle in Symfony 4.3.6 and I'm faced with a problem.
Twig can't render the widget and outputs the following:
An exception has been thrown during the rendering of a template ("Notice: Array to string conversion").
It looks like the issue in the form type options. The attr option contains the options key which is an array (the attr option is an associative array with HTML attributes as keys accordingly to the Symfony docs).
Please fix this issue.
Same problem here, default value for 'attr'=> 'options' is an array and symfony twig bridge is trying to display it... in form_div_layout.html.twig:451
@https://github.com/prugala/PRRecaptchaBundle/issues/22
Same issue happened on the different bundle, temporary solution is to add an entry to twig.yaml configuration under form_themes:
form_themes:
- '@EWZRecaptcha/Form/ewz_recaptcha_widget.html.twig'
Note: ( @excelwebzone , @cloudislam )This entry should be injected automatically by EWZRecaptchaExtension but it doesn't in symfony v4.4
Same issue happened on the different bundle, temporary solution is to add an entry to twig.yaml configuration under form_themes:
form_themes: - '@EWZRecaptcha/Form/ewz_recaptcha_widget.html.twig'
Note: ( @excelwebzone , @cloudislam )This entry should be injected automatically by EWZRecaptchaExtension but it doesn't in symfony v4.4
This problem happens when EWZRecaptchaBundle
is loaded before TwigBundle
.
To fix it you simply need to edit your bundles.php and move the line
EWZ\Bundle\RecaptchaBundle\EWZRecaptchaBundle::class => ['all' => true],
after
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Hello,
I'm facing the same error, Twig bundle is loaded before EWZ and I've added the form_theme but still not working. I've already tried reinstalling the package, changing the order of the bundles, form_themes path with @EWZRecaptcha or %kernel.project_dir% or absolute, nothing work.
I'm using Symfony 5.4 with latest version of EWZ.
Thank you in advance
Edit: I got it to work by adding this directly in my twig template but it's not ideal
{% form_theme form with ['@EWZRecaptcha/Form/ewz_recaptcha_widget.html.twig'] %}