|
|||
|
I'm new to ZF and MVC, and after going through documentation I'm unclear how to use Zend_Form. I understand most of the basic structure, but I don't know where to put the code. Some documentation mentions instantiating Zend_Form, then creating a controller to handle it and a view script to display it. I understand controllers and views, but where do I put the Zend_Form instantiating code?
For an example, the Zend_Form official documentation has a section called "15.2.6. Putting it together" on the following page: Zend Framework: Documentation. I understand the controller and view script code, but where does the first chunk of code go (instantiating Zend_Form and creating username/password elements)? The only place I can think of is the bootstrap file, but I don't think this is the right place. |
|
|||
|
Hi,
probably the good idea is to keep your form creation in separate files, so you'll minimize size of your controller and of course which is most important you can reuse your form later in other controller too (if that can happen). I am using the next way: I have an forms folder where I create my form classes. All my forms inherited Zend_Form so in the constructor you referred the form as $this (don't forget ) then in your controllers you can use the following snippet $form = new My_Form(); if($form->isValid())........ |
![]() |
| Thread Tools | |
| Display Modes | |
|
|