0

I'm developping a website using symfony framework. Now I'm trying to integrate recaptcha into my form so that I used this EWZRecaptchaBundle. I hardly could install it using the 1.* version (not the version mentioned in the documentation). I followed the documentation and get the keys from hereand I put as domain :127.0.0.1 since I'm on localhost. Then I changed my formType.php file like this:

use EWZ\Bundle\RecaptchaBundle\Validator\Constraints as Recaptcha;

class ContactType extends AbstractType
{
/**
* @Recaptcha\True
*/
public $recaptcha;
    /**
 * @param FormBuilderInterface $builder
 * @param array $options
 */
public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('name')
        ->add('email')
        ->add('subject')
        ->add('message')
        ->add('recaptcha', 'ewz_recaptcha')
    ;
}

and added the recaptcha on my twig file like this:

{% form_theme form 'EWZRecaptchaBundle:Form:ewz_recaptcha_widget.html.twig' %}

                      {{ form_widget(form.recaptcha, { 'attr': {
                            'options' : {
                                'theme': 'light',
                                'type': 'image'
                            },
                        } })
                     }}

But when I try to display the page I get : The parameter "fr" must be defined. Looking in the details of the error I found:

at appProdDebugProjectContainer ->getParameter ('fr') 
in C:\wamp\www\fstn\vendor\excelwebzone\recaptcha-bundle\EWZ\Bundle\RecaptchaBundle\Form\Type\RecaptchaType.php at line 62  -
    $this->publicKey = $container->getParameter('ewz_recaptcha.public_key');
    $this->secure    = $container->getParameter('ewz_recaptcha.secure');
    $this->enabled   = $container->getParameter('ewz_recaptcha.enabled');
    $this->language  = $container->getParameter($container->getParameter('ewz_recaptcha.locale_key'));
}
/**

Is it related to the version of the Recaptcha Bundle that I have installed? how can I fix this?

Dev DOS
  • 1,018
  • 4
  • 18
  • 45

1 Answers1

1

Try to change this line:

$this->language = $container->getParameter($container->getParameter('ewz_recaptcha.locale_key'));

to this: $this->language = $container->getParameter('ewz_recaptcha.locale_key');

This issue should be fixed in version 2.X

PsHgZt
  • 11
  • 1
  • But doing that I get this error:`Neither the property "recaptcha" nor one of the methods "getRecaptcha()", "isRecaptcha()", "hasRecaptcha()", "__get()" exist and have public access in class "Fstn\VeniceBundle\Entity\Contact".` looking for the solution in another post :http://stackoverflow.com/questions/8706543/symfony2-add-recaptcha-field-to-registration-form doesn't solve my problem yet. what should I do?can you guide me please? – Dev DOS Apr 13 '15 at 15:15