Open yaroslavolekh opened 5 years ago
$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
https://monosnap.com/file/sSLYmXftJHu6kpkBT8rp9t5FNEHb8V
You might wait for callback