bolt / boltforms

Bolt 3 Forms extension - Symfony interface and API for Bolt
http://bolt.cm
GNU General Public License v3.0
52 stars 57 forks source link

ReCaptcha not rendered after Ajax-submit with incomplete form #117

Open barry-luijten opened 7 years ago

barry-luijten commented 7 years ago

I'm currently using the master branch of BoltForms because I need the Ajax submit functionality. When the form is not completed or does not pass validity checks, the form is rerendered, but the ReCaptcha is not. I have tried to solve this by appending this to the success function of the postForm function (in _ajax.twig):

                var captchas = $('.g-recaptcha');
                for (var i = 0; i < captchas.length; i++) {
                    var c = captchas[i];
                    grecaptcha.render(c, {'sitekey': $(c).data('sitekey')});
                }

This is of course not the most elegant solution, since the Recaptcha is also re-initialized when it was "checked" successfully, but one of the other fields were not (so it has to be re-checked again). I can't come up with another another solution without dissecting the entire BoltForms source code (which is mostly uncharted territory for me ;), so some help will be appreciated! Thanks in advance!

GwendolenLynch commented 7 years ago

@barry-luijten I have tonne of work in motion on BoltForms at the moment, but a number of conflicting deadlines … but will try soon … just only so many hours in the day to get there :smile:

barry-luijten commented 7 years ago

I understand, no worries, the _ajax.twig hack works for me for the time being ;) Thanks!