php - CakePHP edit user gives validationErrror -
i using cakephp application, have user model. user has password, has regex validate. regex forces user use password @ least 6 characters long, containing @ least 1 number , special char.
the validation looks this:
'password' => array( 'rulename' => array( 'rule' => array('custom', '/^.*(?=.{6,})(?=.*\d)(?=.*[a-za-z])(?=.*[@#$%^&+=]).*$/i'), 'message' => 'password not legit', 'allowempty' => true ) ) when want edit password, validation works great. when want edit user (no option change password there), $this->user->save() fails.
if debug $this->user->validationerrors, thing shown is:
array( 'password' => '*****' ) the password field not set in post data, validation should not happen @ all. when comment block of validation code, user can saved.
anyone knows doing wrong?
i solved myself already. before saving user object, did $this->user->read(null, $userid) other purposes.
this resulted in remembering values of read (including password) in $this->user object.
since save method called on $this->user object, password value trying saved too. since *** isn't valid according regex, save fails.
thanks anyway!
Comments
Post a Comment