yii2 验证码
来源:互联网 发布:数控编程方法有哪两种 编辑:程序博客网 时间:2024/04/26 00:51
1111、model
<?phpnamespace frontend\models;use yii;use yii\base\model;class Tu extends Model{ public $verifyCode; public $username; public $password; public function rules() { return [ ['username','required'], ['password','required'], ['verifyCode', 'required'], ['verifyCode', 'captcha'], ]; } public function atrributeLabels(){ return array( 'verifyCode'=>'验证码', ); }}2222、controller<?phpnamespace frontend\controllers;use yii;use yii\web\Controller;use frontend\models\Tu;class TuController extends Controller{ public function actionIndex(){ $model = new Tu(); return $this->render('login', ['model' => $model]); }}3333.view<?phpuse yii\helpers\Html;use yii\widgets\ActiveForm;use yii\captcha\Captcha;$form = ActiveForm::begin([ 'id' => 'login-form', 'options' => ['class' => 'form-horizontal'],]) ?><?= $form->field($model, 'username') ?><?= $form->field($model, 'password')->passwordInput() ?><?= $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>',]) ?> <div class="form-group"> <div class="col-lg-offset-1 col-lg-11"> <?= Html::submitButton('Login', ['class' => 'btn btn-primary']) ?> </div> </div><?php ActiveForm::end() ?>
0 0
- yii2中的验证码
- yii2原生验证码
- yii2的验证码
- yii2图片验证码
- yii2图片验证码
- yii2 验证码
- yii2验证码
- yii2验证码
- yii2 验证码配置
- Yii2验证码
- YII2验证码
- yii2 验证码详细代码
- Yii2.0 使用验证码
- Yii2.0 验证码错误
- Yii2验证码刷新问题
- Yii2.0 添加验证码
- Yii2单独验证图形验证码
- YII2验证
- 扣减库存策略采用订单是否锁定库存方案
- Linux驱动中completion接口浅析(wait_for_complete例子,很好)
- Leetcode 29 - Divide Two Integers(二进制分解)
- 不常见的数据类型
- 源码分析之LayoutInflater
- yii2 验证码
- 判断某个时间在不在某个时间段
- POJ 2104 K-th Number(可持久化线段树)
- 葛洲坝电力集团责任有限公司启动时代新领域核心
- Spring的IOC原理
- 深度学习系列---框架与工具
- c++中sort函数排序自己写的类
- 第二章 变量和基本类型——2.1 基本内置类型((转)附录之原码、反码和补码及其背后的数学之美)
- 正交设计助手的使用教程(设计测试用例的工具)