在更新用户信息的表单中,rules不起作用是怎么回事? [ 新手入门 ]
在更新用户信息的表单中,rules不起作用是怎么回事?注册的的时候验证规则能发挥作用,修改的时候不行,怎么回事?
共 5 条回复
-
public function rules() { // NOTE: you should only define rules for those attributes that // will receive user inputs. return array( array('username, fullname, sex, classroom_id, grade_id', 'required'), array('password,confirmPassword', 'required','on'=>'create'), array('username','unique','on'=>'create,update'),//,'className'=>'User' array('password', 'compare', 'compareAttribute'=>'confirmPassword','on'=>'create,update'), //array('confirmPassword', 'compare', 'compareAttribute'=>'password','on'=>'update'), array('sex', 'numerical', 'integerOnly'=>true), array('username, password, fullname', 'length', 'max'=>16,'on'=>'create'), array('classroom_id, grade_id', 'length', 'max'=>8), array('photo','file','types'=>'jpg,gif,png','maxSize'=>'524288','allowEmpty'=>false,'on'=>'create'), array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()), array('remark', 'safe'), array('fullname', 'match','pattern'=>"/^[\x7f-\xff]+$/",'message'=>"姓名只能是中文!"),//这行也能用。还有说是080 array('username,password', 'match','pattern'=>"/^[".chr(0xa1)."-".chr(0xff)."A-Za-z0-9_]+$/",'message'=>"只允许字母、数字、下划线!"), // The following rule is used by search(). // Please remove those attributes that should not be searched. array('id, username, password, fullname, sex, classroom_id, grade_id', 'safe', 'on'=>'search'), //array('password,confirmPassword','alter_pwd','on'=>'update'), ); }
sxtuwy 山西
注册时间:2011-07-24
最后登录:2013-06-04
在线时长:0小时0分
最后登录:2013-06-04
在线时长:0小时0分
- 粉丝8
- 金钱1645
- 威望0
- 积分1645