【发布时间】:2015-11-19 19:11:15
【问题描述】:
我是 cake 新手,我正在尝试让函数在保存事件后重定向.. 它适用于其他代码,例如用户,但不在事件一中..
该功能确实保存了事件,它只是不会重定向或使用 SETFLASH
这是我的事件控制器添加功能的代码:
public function add() {
if ($this->request->is('post')) {
$this->Event->create();
if ($this->Event->save($this->request->data)) {
$this->Session->setFlash(__('The event has been saved'));
$this->redirect(array('action' => 'eventmanage'));
} else {
$this->Session->setFlash(__('The event could not be saved. Please, contact the administrator.'));
}
}
}
任何帮助将非常感谢!
【问题讨论】:
-
最可能的原因是您的应用程序在发送重定向标头之前输出了一些数据。如果您的文件包含 utf-8 BOM 等,请检查您的
<?php标记之前或?>结束标记之后是否有空格(您应该在仅 php 的文件中删除这些)。您可以通过检查 firebug 或 Chrome webinspector 中的响应来检查这一点 -
谢谢,如果您想要整个
<?php ?>是问题所在,您可以将其发布为答案。非常感谢!! -
我将其发布为答案,很高兴我能提供帮助!
标签: cakephp cakephp-2.3