views:

143

answers:

1

I'm trying to create a contact form. However at the top of the form the user can select using radio buttons whether he's contacting the technical department or the marketing department. Depending on which he selects, the entire form changes.

How would this be implemented within the Zend Framework? I'm already extending Zend_Form to make my forms. Also I'm working within the MVC style and would rather not break out of it.

Right now I simply do

echo $this->form;

in the view to render the form. I'm guessing that when the visitor clicks on one of the radio buttons, the controller will need to set a different form, but I'm not too sure how to go about that without re-rendering the entire page.

Thanks!

EDIT I'm now thinking just setting something like this in the controller:

$this->view->contactFormTechDep = $formTechDep;

$this->view->contactFormMarketingDep = $formMarketingDep;

and render both, but hiding one all using Javascript.

+1  A: 

I think you just need to show/hide the content of the form with JavaScript, not with php. (with jQuery this can easyli be done)

But you'll have to keep in mind to be unobtrusive for users without javascript enabled

Natrium