demi/recaptcha Yii2 wrapper for reCAPTCHA widget

captchawidgetrecaptchagcaptcha

Yii2-reCAPTCHA

Yii2 wrapper for [reCAPTCHA](https://www.google.com/recaptcha/intro/index.html widget)

Installation

Run

composer require "demi/recaptcha" "~1.0"

Configurations


Register new reCAPTCHA API keys

Add keys to /common/config/params.php:

return [
    // reCAPTCHA API keys
    'reCAPTCHA.siteKey' => 'xxxxxxxxx',
    'reCAPTCHA.secretKey' => 'xxxxxxxxx',
];

In the form:

<?= $form->field($model, 'captcha', ['enableAjaxValidation' => false])->label(false)
    ->widget('demi\recaptcha\ReCaptcha', ['siteKey' => Yii::$app->params['reCAPTCHA.siteKey']]) ?>

In the model validation rules:

public function rules()
{
    return [
        // captcha
        [
            ['captcha'], 'demi\recaptcha\ReCaptchaValidator', 'secretKey' => Yii::$app->params['reCAPTCHA.secretKey'],
            'when' => function ($model) {
                /** @var $model self */
                return !$model->hasErrors() && Yii::$app->user->isGuest;
            }
        ],
}

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



1.0.1 is the latest of 3 releases



GPL-3.0-or-later license
Stats
0 github stars & 0 github forks
0 downloads in the last day
0 downloads in the last 30 days
707 total downloads