zend_form: should I use one right in the layout

hellohitomi

New Member
I usually instantiate my forms in an action and that's where I process them when they're submitted. I then pass them on to the view and output them there as usual.This form (a search box) is different because it's not part of a single page. It has to be visible everywhere. I've made it part of the template \[code\]layout.phtml\[/code\] and instantiated and accessed it right there. \[code\]$search = new SearchForm(); echo $search;\[/code\]The form prints out fine but the question now is where do I handle this form. I usually have processing code like this in the action.. \[code\] if ($this->_request->isPost()) { //and form is valid //process the data }\[/code\]but since this form is universal, there's no action for it. How should I handle this? Should I:
  • create a dummy action for it (which doesn't make sense because the form is everywhere)
  • or should I put the processing code right into the layout.phtml (which I think is bad MVC practice because I'm now mixing processing the form with the view).
What should I do? Any advice on this?
 
Top