Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught ReferenceError: grecaptcha is not defined #1

Open
yaroslavolekh opened this issue Feb 14, 2019 · 1 comment
Open

Uncaught ReferenceError: grecaptcha is not defined #1

yaroslavolekh opened this issue Feb 14, 2019 · 1 comment

Comments

@yaroslavolekh
Copy link

yaroslavolekh commented Feb 14, 2019

https://monosnap.com/file/sSLYmXftJHu6kpkBT8rp9t5FNEHb8V

You might wait for callback

@yaroslavolekh
Copy link
Author

$this->getView()->registerJsFile('https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit', [
'async' => 'async',
'defer' => 'defer'
]);
...
return Html::activeHiddenInput($this->model, $this->attribute)
. Html::button($this->buttonText, $options)
. Html::tag('script', <<<JS
window.recaptchaCallback_{$callbackRandomString} = function() {
$('#{$inputId}').val($('#{$recaptchaId}').val());
$('#{$formId}').submit();
}

            window.onloadCallback = function() {
              grecaptcha.render('recaptchaButton{$callbackRandomString}'); 
            }

JS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant