Google ReCaptcha v2.0 Yii 2.x.x extension
PHP
Latest commit b410ee8 Jan 27, 2017 @brussens init
Permalink
Failed to load latest commit information.
src init Jan 27, 2017
LICENSE Initial commit Jan 27, 2017
README.md init Jan 27, 2017
composer.json init Jan 27, 2017

README.md

Google ReCaptcha v2.0 Yii 2.x.x extension

Latest Stable Version Total Downloads License

Install

Either run

php composer.phar require --prefer-dist brussens/yii2-recaptcha "*"

or add

"brussens/yii2-recaptcha": "*"

to the require section of your composer.json file.

Add to your config file:

'components' => [
    ...
    'recaptcha' => [
        'class' => 'brussens\\yii2\\extensions\\recaptcha\\Component',
        'siteKey' => '!!!Insert your public key here!!!',
        'secretKey' => '!!!Insert your secret key here!!!'
    ],
    ...
],

Add in your model validation rules

public function rules()
{
    return [
        ...
        ['verifyCode', \brussens\yii2\extensions\recaptcha\Validator::className()],
        ...
    ];
}

Add in your view

echo $form->field($model, 'verifyCode')->widget(\brussens\yii2\extensions\recaptcha\Widget::className());

If you use Pjax or multiple widgets on page

echo $form->field($model, 'verifyCode')->widget(
    \brussens\yii2\extensions\recaptcha\Widget::className(), [
    'options' => [
        'id' => 'insert-unique-widget-id'
    ]
]);