dev-master
9999999-devYii2 Google reCAPTCHA widget
MIT
The Requires
The Development Requires
by Ganesh
yii2 captcha google widget recaptcha
Yii2 Google reCAPTCHA widget
Based on reCaptcha API 2.0., (*1)
The preferred way to install this extension is through composer., (*2)
php composer.phar require --prefer-dist "alkurn/yii2-recaptcha" "dev-master"
or add, (*3)
"alkurn/yii2-recaptcha" : "*"
to the require
section of your application's composer.json
file., (*4)
Configure the component in your configuration file (web.php). The parameters siteKey and secret are optional. But if you leave them out you need to set them in every validation rule and every view where you want to use this widget. If a siteKey or secret is set in an individual view or validation rule that would overrule what is set in the config., (*6)
'components' => [ 'reCaptcha' => [ 'name' => 'reCaptcha', 'class' => 'alkurn\recaptcha\ReCaptcha', 'siteKey' => 'your siteKey', 'secret' => 'your secret key', ], ...
ReCaptchaValidator
in your model, for example:public $reCaptcha; public function rules() { return [ // ... [['reCaptcha'], \alkurn\recaptcha\ReCaptchaValidator::className(), 'secret' => 'your secret key'] ]; }
or just, (*7)
public function rules() { return [ // ... [[], \alkurn\recaptcha\ReCaptchaValidator::className(), 'secret' => 'your secret key'] ]; }
or simply, (*8)
public function rules() { return [ // ... [[], \alkurn\recaptcha\ReCaptchaValidator::className()] ]; }
For example:, (*9)
<?= $form->field($model, 'reCaptcha')->widget( \alkurn\recaptcha\ReCaptcha::className(), ['siteKey' => 'your siteKey'] ) ?>
or, (*10)
<?= \alkurn\recaptcha\ReCaptcha::widget([ 'name' => 'reCaptcha', 'siteKey' => 'your siteKey', 'widgetOptions' => ['class' => 'col-sm-offset-3'] ]) ?>
or, (*11)
<?= $form->field($model, 'reCaptcha')->widget(\alkurn\recaptcha\ReCaptcha::className()) ?>
or simply, (*12)
<?= \alkurn\recaptcha\ReCaptcha::widget(['name' => 'reCaptcha']) ?>
Yii2 Google reCAPTCHA widget
MIT
yii2 captcha google widget recaptcha