搞搞的传奇
- 搞搞的传奇 提出了问题为嘛我的确认删除不跳出来
- 搞搞的传奇 2015-09-29 已签到连续签到2天,获得了10个金钱
Model的rules()中的captcha规则中的captchaAction选项和View中widget的captchaAction选项要一致。都是指向控制器中的actions()函数中引入的captcha。没有指定,框架使用默认值。
你可以按这几个步骤定位问题:
- 检查一下你的页面是否有验证码显示,如果没有说明widget找不到
captchaAction
(没有指定时使用框架默认)。 - 如果有,看页面源码的src路径,是否和你的controller路由(看你的网址)一致:
<img id="signupform-verifycode-image" src="/admin/auth/captcha?v=56073d7b671c6" alt="">
- 以上这个
一致
不是强求的,src的路径可以使用其他位置(路由)的captcha。 - 最后,你的validate()是用model规则中的captchaAction去验证的(没有指定时使用框架默认),和view的不一致肯定失效。
另外,你的model规则的写法,建议用框架的
guide
所说的格式,以下Model的rules()供参考:class SignupForm extends Model { public $first_name; public $last_name; public $username; public $email; public $password; public $password2; public $verifyCode; /** * @inheritdoc */ public function rules() { return [ #username, 用户名改成系统自动产生的数字,基数为YYYYMM00001 #first_name, last_name [['first_name','last_name'], 'required'], [['first_name','last_name'], 'string', 'min' => 1, 'max' => 32], #email ['email', 'filter', 'filter' => 'trim'], ['email', 'required'], ['email', 'email'], ['email', 'unique', 'targetClass' => '\app\modules\admin\models\User', 'message' => 'This email address has already been taken.'], #password ['password', 'required'], ['password', 'string', 'min' => 6], ['password2', 'compare', 'compareAttribute' => 'password', 'message'=>'Password repeat is inconsistent with password.'], #captcha ['verifyCode', 'captcha', 'captchaAction'=>'/admin/auth/captcha'], ]; }
谢谢您的答复,按你的思路,我也去走了一遍,没错的。自己新装了yii2和yii2-user,始终是一样的错误,用yii2自带的loginfrom模型,就没错的,打印了yii\captcha\CaptchaAction 的 validate,session和post过来数据节拍对不上。问了作者,一口咬定是没问题的,关闭了我的问题。哎,水平不行找不到原因
- 检查一下你的页面是否有验证码显示,如果没有说明widget找不到
- 搞搞的传奇 2015-09-28 已签到连续签到1天,获得了5个金钱
- 搞搞的传奇 评论了教程 YII安装时的简单配置
很好很好!