Open antoine1003 opened 5 years ago
Hi antoine1003
When you install the bundle and also the recipe, you have a custom one in config/packages/dev/wez_recaptcha.yaml
.
In this the captcha is disabled (enabled: false
).
Set it to enabled: true
and you will see it in the form.
Same issue here with symfony 5.4. The label is displayed but nothing else. It is not related to the enabled parameter.
Something is strange because it is working well on another project with the same symfony version.
@antoine1003 do you remember how did you solve this old problem ?
Thx
Hey @benjamin-aubry , Unfortunatly I couldn't solve this problem... So I removed this package and added manualy a recaptcha in the form template
<!-- Sample of my form -->
<div class="form-group">
{{ form_row(form.body) }}
</div>
<div class="form-group">
<div name="captcha" class="g-recaptcha" data-sitekey="{{ captcha_public }}"></div>
</div>
<!-- [...] -->
{% block javascript %}
<script src='https://www.google.com/recaptcha/api.js'></script>
{% endblock %}
The captcha_public
is set in my config/services.yaml
:
captcha_public: 'my-google-key'
and in the config/packages/twig
twig:
globals:
captcha_public: '%captcha_public%'
And use google/recaptcha package to check in in my controller :
if ($form->isSubmitted() && $form->isValid()) {
$recaptcha = new ReCaptcha($params->get('captcha_secret'));
$resp = $recaptcha->verify($request->request->get('g-recaptcha-response'), $request->getClientIp());
$contact = $form->getData();
$nbError = 0;
if (!$resp->isSuccess()) {
$message = $translator->trans('error.bad_captcha');
// Do something if the submit wasn't valid ! Use the message to show something
$this->addFlash('error', $message);
$nbError ++;
}
// ...
}
I don't know if it helps but thats how I handled it 😃
Thx ! I let you know if I find what the problem is.
Finallly in my case it was a config issue, I didn't notice that there is 2 config files so the solution given by @urkob worked.
Thx !
Hi,
I installed this pluggin follow all steps but when I add the line :
->add('recaptcha', EWZRecaptchaType::class)
the form id not rendered.Here is aa photo of the bottom of my form :
The html of the field is :
Do you have any idea of what is happening?