[EXTENSION] defaultpersister

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:

http://www.yiiframework.com/extension/defaultpersister/

Questions and suggestions are welcome.

Updated to 1.1.0:

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.

Big congratulations Mike, it is a very useful, very good extension.

Thanks, Antonio.

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 :)

Impressive…