Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-13-2008, 05:00 AM
BJM BJM is offline
Junior Member
 
Join Date: Apr 2008
Posts: 8
Default Zend_Form .. where does the code go?

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-14-2008, 04:05 AM
Junior Member
 
Join Date: Mar 2008
Posts: 6
Default

The entire putting it together code should be in your action controller.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-18-2008, 09:05 AM
Junior Member
 
Join Date: Apr 2008
Posts: 7
Default

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())........
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:37 AM.