Question

I'm using Zend Framework and come up with a situation of forwarding a request to another action in same controller.

I'm forwarding the request from create to save. What I want to do is to check (from saveAction) whether the request is forwarded or a direct request (without using any additional variables or parameters)

init() function will be triggered twice for each forwarding (one for create and one for save), and it would be better check from init() too.

class Cms_UserController extends Zend_Controller_Action {

    public function init() {
        parent::init();

        // some code here
    }

    public function createAction() {

        if (!$this->getRequest()->isPost()) {
            // forwarding to cms/user/save
            return $this->_forward('save');
        }

        // do some stuff for POST request
    }

    public function saveAction() {
        // I want to check whether the request is
        // forwarded from 'createAction' or from any action
        // or a direct request to cms/user/save
    }

}
Was it helpful?

Solution

Hope this will help you:

public function lastAction(){
    $request=$this->getRequest()->getParams();
    $request['action']; //you can get corresponding actions here
}
public function testAction(){
    return $this->_forward('last');
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top