我想在类似下面的代码的场景中设置安全或允许空验证码。
var date = new Date();
var month = new Array();
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";
[month[n-3],month[n-2], month[n-1], month[n]]
但它不起作用,我收到了这个错误。
public function rules() {
return [
[['verifyCode'], 'safe', 'on'=>'admin'],
];
}
并且this page也没有帮助我。
答案 0 :(得分:2)
试试这个。添加规则:
[['verifyCode'], 'captcha', 'skipOnEmpty' => true, 'on'=>'admin']
在控制器中,当创建实例时:
$model->scenario = 'admin';