The preferred way to install this extension is through Composer.
Either run
php composer.phar require gbksoft/yii2-recaptcha-widget "*"
or add
"gbksoft/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',
\gbksoft\recaptcha\validators\RecaptchaValidator::class,
'secret' => '<your-secret>'
]
];
}
Add field to view:
<?= $form->field($model, 'captcha')->widget(\gbksoft\recaptcha\widgets\Recaptcha::class, [
'clientOptions' => [
'data-sitekey' => '<your-sitekey>'
]
]) ?>