Beforesave/aftervalidate Alternative

Hello, I am having a little problem finding alternatives for beforeSave/afterValidate, basically I need to hash passwords before user creates his/her account (I am using afterValidate for this), it all works fine, however, when user wants to update his/her account (e.g. insert First/Last names etc.) the password changes as afterValidate kicks in every time before I save() model. Is there any alternative to hash password before saving record, but not using afterValidate or beforeSave?

There is one solution for that.

While updating record, Check if the password field is empty then don’t make md5 of that string if not empty then take new string as new password and make md5 of that string and update in Database. For that you can use setAttribute() function of YII for storing password.

While updating a record, give password field empty by default and if user wants to change password then he will insert text if not then user will keep it empty.

Hi,

Below link can help you to solve your problem

http://www.yiiframework.com/forum/index.php/topic/3886-jformvalidate-extension-validate-required-field-even-when-it-shouldnt/page__p__21875#entry21875

http://www.yiiframework.com/forum/index.php?/topic/6451-rehash-password-only-when-changed

khush@l, much appreciated, very fast reply, easy implementation, works perfectly =]

Its my pleasure!!!

Cheers… :)