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?
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.