Kohana redirect

半世苍凉 提交于 2019-12-11 05:05:17

问题


After a form-submit in Kohana, I want the user to go back to the homepage. Is it correct to use a redirect for this?

public function action_edit($id)
{
    if (!empty($post))
    {
        if ($post->validate())
        {
            $this->request->redirect(Route::get('admin')->uri(array('action' => 'list')));

        }
    }
}

Thanks in advance!


回答1:


Sometimes $this->request->uri($params) (instead of Route::get()->uri()) maybe useful. For example, when you want to use current controller (redirect to another action) or the same route. It will use route params from current request by default.




回答2:


The redirecting part is indeed correct. The validation part is missing a few lines.



来源:https://stackoverflow.com/questions/5484206/kohana-redirect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!