excelwebzone / EWZRecaptchaBundle

This bundle provides easy reCAPTCHA form field for Symfony.
MIT License
396 stars 160 forks source link

[Question|Issue] Bundle not triggering frontend validation #300

Open entobvba opened 1 year ago

entobvba commented 1 year ago

Hi,

thanks for the bundle/code. Nice work and I use it a lot.

I'm having an issue where the frontend validation is not triggered. I think the issue is that the javascript uses "submit" and not "requestSubmit" here:

https://github.com/excelwebzone/EWZRecaptchaBundle/blob/master/src/Resources/views/Form/v3/ewz_recaptcha_widget.html.twig

Not sure, so raising it as an question for now. When confirmed I can issue a PR.

See also: https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/requestSubmit

The obvious question is: Why does this method exist, when we've had the submit method since the dawn of time?

The answer is simple. submit() submits the form, but that's all it does. 
requestSubmit(), on the other hand, acts as if a submit button were clicked. 
The form's content is validated, and the form is submitted only if validation succeeds. 
Once the form has been submitted, the submit event is sent back to the form object.