Adrian Schneider’s Blog: Caching Zend Framework Forms
On his blog Adrain Schneider shares his ideas about using Zend_Form component. In his first post he talks about typical use cases of the component – defining inputs, filtering, validation, using models and decorators.
I’m often asked what my favorite component of Zend Framework is, and I invariably answer: “Forms”. Forms have always played an awkward role in the model-view-controller paradigm. Sure, the form is just HTML, but to me, it represents something more abstract than that. It represents the HTML form itself, taking user input, normalizing and validating it, and also being able to show the form again when errors occur. This can take quite a large amount of code.
In the second post he presents his way of speeding up forms by introducing caching.
Generating a form is an expensive process in ZF. It’s always bugged me that I can’t find any resources on trying to cache the initial HTML anywhere, so I took a stab at it myself. I use a loader from inside my controller action to load forms and models, so I found that was a good place to start.