himiklab\yii2\recaptcha\ReCaptcha::customFieldPrepare PHP Method

customFieldPrepare() protected method

protected customFieldPrepare ( )
    protected function customFieldPrepare()
    {
        $view = $this->view;
        if ($this->hasModel()) {
            $inputName = Html::getInputName($this->model, $this->attribute);
            $inputId = Html::getInputId($this->model, $this->attribute);
        } else {
            $inputName = $this->name;
            $inputId = 'recaptcha-' . $this->name;
        }
        if (empty($this->jsCallback)) {
            $jsCode = "var recaptchaCallback = function(response){jQuery('#{$inputId}').val(response);};";
        } else {
            $jsCode = "var recaptchaCallback = function(response){jQuery('#{$inputId}').val(response); {$this->jsCallback}(response);};";
        }
        $this->jsCallback = 'recaptchaCallback';
        if (empty($this->jsExpiredCallback)) {
            $jsExpCode = "var recaptchaExpiredCallback = function(){jQuery('#{$inputId}').val('');};";
        } else {
            $jsExpCode = "var recaptchaExpiredCallback = function(){jQuery('#{$inputId}').val(''); {$this->jsExpiredCallback}(response);};";
        }
        $this->jsExpiredCallback = 'recaptchaExpiredCallback';
        $view->registerJs($jsCode, $view::POS_BEGIN);
        $view->registerJs($jsExpCode, $view::POS_BEGIN);
        echo Html::input('hidden', $inputName, null, ['id' => $inputId]);
    }