Blog

FormSession - a CakePHP component to keep form data between actions

Ever serve forms from actions that POST to other actions? Wondered why you lose the form data, or you don't get back validation errors? These bits of information are unfortunately only stored as variables within the current scope in Cake, and if you redirect back to the action that served the form, it's all lost.

Unless you store it to Session.

That's what the FormSession component does. It provides an easy access ability to store and retrieve a Model's data and validation errors to Session, thereby being able to use them across actions, or even controllers!

The component itself has been turned into a plugin at the behest of savant, a regular in the CakePHP IRC channel, and is also available at github.

 

Questions or suggestions? Feel free to comment to this post.

Site Goes Live

withoutboundary goes Live!

Keep your eye on this space for articles about CakePHP, jQuery, Javascript, PHP, CSS, and basically anything to do with website development.