yii-验证码

1.模型层demo:

引用小部件:

use yii\captcha\Captcha;

定义变量:

public $verifyCode;

验证规则:

['verifyCode', 'captcha','message'=>'验证码错误'],

2.视图层demo:

引用小部件:

use yii\captcha\Captcha;

添加验证码:

<?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [ 'template' =>'<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>',]) ?>

你可能感兴趣的:(yii-验证码)