ReCaptcha.php
public function registerClientScript($gCaptchaParams = [])
    {
        $id = $this->id;
        $view = $this->view;
        ReCaptchaAsset::register($view);

        $options = Json::encode($gCaptchaParams);

        // Directly creating captcha widgets.
        // This code placed only one time irrespective of count of captcha-widgets
        $view->registerJs(<<<JS
if (typeof (renderReCaptchaCallback) === "undefined") {
    var reCaptchaWidgets = {};
    var renderReCaptchaCallback = function() {
        for (var widgetId in reCaptchaWidgets) {
            if (reCaptchaWidgets.hasOwnProperty(widgetId)) {
                grecaptcha.render(document.getElementById(widgetId), reCaptchaWidgets[widgetId]);
            }
        }
    };
}
JS
            , View::POS_HEAD, 'renderReCaptchaCallbackFunction');

        // Append new captcha widget info
        $view->registerJs(<<<JS
reCaptchaWidgets.$id = $options;
JS
            , View::POS_HEAD);
    }
public function registerClientScript($gCaptchaParams = [])
    {
        $id = $this->id;
        $view = $this->view;
        ReCaptchaAsset::register($view);

        $options = Json::encode($gCaptchaParams);

        // Directly creating captcha widgets.
        // This code placed only one time irrespective of count of captcha-widgets
        $view->registerJs(<<<JS
if (typeof (renderReCaptchaCallback) === "undefined") {
    var reCaptchaWidgets = {};
    var renderReCaptchaCallback = function() {
        for (var widgetId in reCaptchaWidgets) {
            if (reCaptchaWidgets.hasOwnProperty(widgetId)) {
                grecaptcha.render(document.getElementById(widgetId), reCaptchaWidgets[widgetId]);
            }
        }
    };
}
JS
            , View::POS_HEAD, 'renderReCaptchaCallbackFunction');

        // Append new captcha widget info
        $view->registerJs(<<<JS
reCaptchaWidgets.$id = $options;
JS
            , View::POS_HEAD);
    }
public function registerClientScript ( $ gCaptchaParams = [ ] ) { $ id = $ this -> id ; $ view = $ this -> view ; ReCaptchaAsset :: register ( $ view ) ; $ options = Json :: encode ( $ gCaptchaParams ) ; // Directly creating captcha widgets. // This code placed only one time irrespective of count of captcha-widgets $ view -> registerJs ( <<<JS
if (typeof (renderReCaptchaCallback) === "undefined") {
    var reCaptchaWidgets = {};
    var renderReCaptchaCallback = function() {
        for (var widgetId in reCaptchaWidgets) {
            if (reCaptchaWidgets.hasOwnProperty(widgetId)) {
                grecaptcha.render(document.getElementById(widgetId), reCaptchaWidgets[widgetId]);
            }
        }
    };
}
JS , View :: POS_HEAD , 'renderReCaptchaCallbackFunction' ) ; // Append new captcha widget info $ view -> registerJs ( <<<JS
reCaptchaWidgets.$id = $options;
JS , View :: POS_HEAD ) ; }
Register google reCAPTCHA js api and custom render scripts

@param array $gCaptchaParams
Register google reCAPTCHA js api and custom render scripts