This is an extension that can be used to easily save and load default values of any model. I use it e.g. to save current settings of a filter model to session. Later when a backend user comes back to the page, the same filter settings will be provided for convenience.
Check out the extension page for more details and a full usage example:
The extension now also allows to load ActiveRecord attributes that where defined in the model file only.
resetDefaults() can be used to reset (clear) attributes. If no argument is supplied, all values will be cleared. It can also be called with a single attribute name or an array of names that should be cleared.
In fact i really got used to this little helper. For example it’s useful if you want to create wizard like forms over multiple pages: I create scenarios for each page and if a page validates i use saveAsDefaults() to remember the form inputs. Only after the last page i call save() to finally store the data to DB. Works like a charm