{% block ewz_recaptcha_widget %} {% apply spaceless %} {% if form.vars.ewz_recaptcha_enabled %} {% if form.vars.ewz_recaptcha_hide_badge %} {% endif %} {{ form_widget(form) }} var grecaptchaInput = document.getElementById('{{ id }}'); grecaptchaInput.value = ''; // Always reset the value to get a brand new challenge var grecaptchaForm = grecaptchaInput.form; grecaptchaForm.addEventListener('submit', function (e) { e.preventDefault(); grecaptcha.ready(function () { grecaptcha.execute('{{ form.vars.public_key }}', { action: '{{ form.vars.action_name|default(constant('EWZ\\Bundle\\RecaptchaBundle\\Form\\Type\\EWZRecaptchaV3Type::DEFAULT_ACTION_NAME')) }}' }).then(function (token) { grecaptchaInput.value = token; HTMLFormElement.prototype.submit.call(grecaptchaForm); }); }); }, false); {% endif %} {% endapply %} {% endblock %}