Set Flag Only If Attribute Values Have Changed

I have a basic form which displays user details. When a user updates his/her details, it sets a flag ‘is_changed’ to true and the record then appears in the admin to be approved.

Sometimes a user may open the form and just click submit at the bottom without making any changes. How can I check in my controller action if model attribute values have changed?

  1. create private variable to store original values

  2. assign a value to it in afterFind

  3. check if modified in beforeSave

  4. profit!

Take a look at this extension: attributesbackupbehavior.

Probably, it’s what you are looking for.

ORey - can you provide an example code for this?