Validations are run on clean attributes
When I try to save my User model and do not pass the password to update_attributes, I'd expect the password to not be validated. But instead it tries to validate the hashed password which is stored in the database, which won't validate.
Is there a way to only validate attributes when they're dirty? And shouldn't this be the default behavior? Or has it be done using a custom validate function on the model?
I am observing the same issue any suggestions?
I believe this will be fixed when #464 lands
can you please send me your fix. As I can't wait for that. My Email: [email protected]
You can view the diff: https://github.com/jpfuentes2/php-activerecord/pull/464/files and download it as patch: https://github.com/jpfuentes2/php-activerecord/pull/464.patch or diff patch: https://github.com/jpfuentes2/php-activerecord/pull/464.diff
Thanks koenpunt :)
Koenpunt I made your changes in Model class, but still getting same issue. I am finding user by
$user = $this->model->find(array('conditions' => array('id = ?', $user_id))); then updating some attributes as: $user->first_name = $first_name; I am not changing value of password
Then $user->save(), returns validation error for password validation. Is there anything that I am missing?
just for record I am using 1.1-dev branch i.e. (https://github.com/jpfuentes2/php-activerecord/tree/1.1-dev)