ZEND Controllers -- How to call an action from a different controller

user225195 picture user225195 · Dec 5, 2009 · Viewed 14.9k times · Source

I want to display a page that has 2 forms. The top form is unique to this page, but the bottom form can already be rendered from a different controller. I'm using the following code to call the action of the other form but keep getting this error:

 "Message: id is not specified"

 #0 .../library/Zend/Controller/Router/Rewrite.php(441): Zend_Controller_Router_Route->assemble(Array, true, true)

My code:

First controller:

abc_Controller
public function someAction()
{

    $this->_helper->actionStack('other','xyz');

}

Second controller:

    xyz_Controller
 public function otherAction()
 {
 // code
 }

Desired results:

When calling /abc/some, i want to render the "some" content along with the xyz/other content. I think I followed the doc correctly (http://framework.zend.com/manual/en/zend.controller.actionhelpers.html) but can't find any help on why that error occurs. When I trace the code (using XDebug), the xyz/other action completes ok but when the abc/some action reaches the end, the error is thrown somewhere during the dispatch or the routing.

Any help is greatly appreciated.

Answer

Akeem picture Akeem · Dec 5, 2009

You can accomplish this in your phtml for your someAction. So in some.phtml put <?php echo $this->action('other','xyz');?> this will render the form found in the otherAction of XyzController