The preferred way to install this extension is through Composer.
Either run
php composer.phar require zelenin/yii2-recaptcha-widget "*"
or add
"zelenin/yii2-recaptcha-widget": "*"
to the require section of your composer.json
Register a new site.
Add captcha attribute to model:
public $captcha;
public function rules()
{
return [
[
'captcha',
'Zelenin\yii\widgets\Recaptcha\validators\RecaptchaValidator',
'secret' => '<your-secret>'
]
];
}
Add field to view:
<?= $form->field($model, 'captcha')->widget('Zelenin\yii\widgets\Recaptcha\widgets\Recaptcha', [
'clientOptions' => [
'data-sitekey' => '<your-sitekey>'
]
]) ?>
Aleksandr Zelenin, e-mail: aleksandr@zelenin.me
Comments