2017-07-13 2 views
0

J'essaie d'intégrer le BeelabRecaptcha2Bundle dans mon projet. En tant que tel, je veux nommer le champ reCaptcha lui-même g-recaptcha-response. Quand je l'ajoute à mon modèle Brindille, je reçois l'erreur suivante:Symfony 3.3 - Erreur d'exécution Twig avec le nom du widget de forme trait d'union

Uncaught PHP Exception Twig_Error_Runtime: "Neither the property "g" nor one of the methods "g()", "getg()"/"isg()"/"hasg()" or "__call()" exist and have public access in class "Symfony\Component\Form\FormView"

est ici l'infraction Code Brindille:

<div> 
    {{ form_widget(form.g-recaptcha-response) }} 
</div> 

Comment puis-je obtenir ce travail?

Répondre

2

Essayez

<div> 
    {{ form_widget(form['g-recaptcha-response']) }} 
</div> 

ou

<div> 
    {{ form_widget(attribute(form, 'g-recaptcha-response')) }} 
</div> 

Vous pouvez en lire plus à ce sujet dans le docs.