$ dispatcher-> forward()执行后处理URI

时间:2013-02-25 03:13:31

标签: php dispatcher phalcon

我已将表单提交URI设置为'/register'和控制器操作$dispatcher->forward()'/profile'之类的内容。提交表单时,它会转发到正确的页面,但浏览器中显示的URI为'/register'。有没有办法将URI设置为$dispatcher->forward()方法中定义的URI而不是表单操作?

1 个答案:

答案 0 :(得分:1)

您可以使用redirect方法。

所以在你的控制器中你可以做到:

public function registerAction()
{
    $this->view->disable();

    if ($this->request->isPost()) {

        // Here is where you process the POST and check the user

        if ($user) {

            // Valid user
            $this->flash->success('OK');
            return $this->response->redirect('profile');

        } else {

            $this->flash->error('Oops! Something went wrong.');

        }

    }
}