We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

how to use $this->dispatcher->forward with modules?

how to use $this->dispatcher->forward with modules?

        $this->dispatcher->setModuleName('backend');
        return $this->dispatcher->forward(
            [
                "namespace"  => "Application\Controllers\Backend",
                "module"     => "backend",
                "controller" => "node",
                "action"     => "new",
            ]
        );

don't work

or how saving GET/POST variables on redirection? or redirect with parameters or form data



43.9k
edited Oct '16

Hi,

don't work

what do you exactly get ?

from: https://docs.phalcon.io/en/latest/api/Phalcon_Mvc_Dispatcher.html (function: forward)

Forwards the execution flow to another controller/action Dispatchers are unique per module. Forwarding between modules is not allowed

Maybe redirect can help you: https://docs.phalcon.io/en/latest/reference/response.html#making-redirections

edited Oct '16

Short answer - you can't.

Longer answer - you need to load proper namespace from other module to which you want forward to in module from which you are forwarding. and use namespace parameter in forward. Keep in mind that any services, classes etc used in this other module and controller you need to register them as well in your current module.

Module key in forward is not even needed.