开发者

Zend Framework Action Helper Problem

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开发者_JAVA技巧($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?


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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜