我在Cakephp中遇到以下问题:我使用CakePhp编辑CMS来编辑网站内容.现在,当我更改表单中的内容并单击"保存"时,他再次显示表单更改之前的数据.在数据库中,一切都保存得很好,如果我刷新页面,他也会显示正确的数据.
我知道我可以渲染一个新页面或重定向到另一个页面,但我喜欢用setFlash显示一条消息,就是这样.有人可以帮帮我吗?
提前致谢
亚伦
Mou*_*oud 15
更新:检查下面的Justin T.解决方案.
您只需重定向到同一页面:
设置您的Flash消息:
$this->setFlash('blablablabla');
Run Code Online (Sandbox Code Playgroud)
和
return $this->redirect($this->here); //cake 1.3
Run Code Online (Sandbox Code Playgroud)
要么
return $this->redirect($this->request->here); // cake 2.x
Run Code Online (Sandbox Code Playgroud)
要么
return $this->redirect(['controller' => 'MyController', 'action' => 'methodOfController']); // cake3.X
Run Code Online (Sandbox Code Playgroud)
重定向.