2017 © Pedro Peláez
 

yii2-extension yii2-recaptcha-widget

Yii2 Google reCAPTCHA widget

image

sashsvamir/yii2-recaptcha-widget

Yii2 Google reCAPTCHA widget

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 63 % Grown

The README.md

ReCaptcha Widget

Widget to render google recaptcha and validate this field., (*1)

This implementaion allow to use: - multiple widgets on one page - also you can load page by ajax several times, (*2)

recaptcha, (*3)

Information

Now this widget extends himiklab/yii2-recaptcha-widget extension (automatic loading as depends in composer.json), (*4)

Installation

Just add extension to composer require section:, (*5)

composer require sashsvamir/yii2-recaptcha-widget:"dev-master", (*6)

Setup

Setup recaptcha config common/config/main.php:, (*7)

'components' => [
    // ...
    'reCaptcha' => [
        'name' => 'reCaptcha',
        'class' => 'sashsvamir\yii2\recaptcha\ReCaptcha',
        'siteKey' => '<your site public key>',
        'secret' => '<your site private key>',
    ],
],

To debug, use follow keys:, (*8)

'siteKey' => '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI',
'secret' => '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe',

see: https://developers.google.com/recaptcha/docs/faq, (*9)

Using

Add ReCaptchaValidator in your model, for example:, (*10)

public $verifyCode;

public function rules()
{
  return [
    // ...
    ['verifyCode', ReCaptchaValidator::className(), 'uncheckedMessage' => 'Please confirm that you are not a bot.',
      // add follow lines to prevent checking recaptcha when from has errors 
      'when' => function ($model) {
        return !$model->hasErrors();
      }
    ],
  ];
}

Render ReCaptcha field:

$form->field($model, 'verifyCode')->widget(\sashsvamir\yii2\recaptcha\ReCaptcha::className())->label(false);

The Versions

24/01 2018

dev-master

9999999-dev

Yii2 Google reCAPTCHA widget

  Sources   Download

MIT

The Requires

 

yii2 captcha google widget recaptcha