views:

62

answers:

1

Hi, I'm a relative noob when it comes to Zend Framework, however I've got a form that I need to use if a couple of views so I thought I might use a Action Helper to instantiate the form set a few attributes and pass it to the relevant view. I've created the Action Helper and can call it from within the relevant controller's action, however when I try to pass the form to the action's view nothing gets rendered, ie:

$form = new Application_Form_Colour;
if($this->_request->isPost() && $form->isValid($this->_request->getPost()))
{
    $model = new Application_Model_Colour();
    $model->changeColour($form->getValues());  
    $form->reset();
}
else
{
    $form->newColour->setAttrib('disabled', 'disabled');
}
$this->view->form = $form;

Is there something I am doing wrong or have I got the wrong idea of what an Action Helper can be used for? Maybe its not an Action helper that I need to use?

A: 

It turned out I was just being stupid! Instead of

$this->view->form = $form;

at the end of the Action Helper I should have done:

return $form;

Then in my controller:

$this->view->form = $this->_helper->myActionHelper->myActionHelperMethod();

Silly me...

John