Yii2 signup captcha


/ Published in: PHP
Save to your folder(s)

First, for SignUp Model.

Second, for signup view.


Copy this code and paste it in your HTML
  1. public $verifyCode;
  2. ['verifyCode', 'captcha'],
  3. ['verifyCode', 'required'],
  4.  
  5.  
  6. <?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [
  7. 'template' => '<div class="row"><div class="col-lg-4">{image}</div><div class="col-lg-6">{input}</div></div>',
  8. ]) ?>
  9. <div style="color:#999;margin:1em 0">
  10. <?= Yii::t('app', 'Click on the image to get a new verification code.') ?>
  11. </div>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.