Model Beforesave

Hello,

In my model I have beforeSave method which hash password and do other things. But in some situation I want to pass it. Is there a way not to execute beforeSave when I want?

Thank you.

How about setting up a virtual attribute and if it’s false then skip your custom code?

It’s an idea. Thank you.

This would be the easy way. The elegant and harder way would be to override the onBeforeSave event to keep your code from executing. AFAIK if you use ActiveRecord you can’t avoid beforeSave at some point.

Good luck.

Maybe it will be better to try with override.

Thank you again,

That’s OOP, inherit your parent class, and create your own child :)