【发布时间】:2010-12-24 20:25:13
【问题描述】:
我正在使用 CakePHP 博客示例:
function add() {
if (!empty($this->data)) {
if ($this->Post->saveAll($this->data)) {
$this->Session->setFlash('Your post has been saved.');
$this->redirect(array('action' => 'index'));
}
}}
我想修改它,让用户在添加后重定向到帖子:
但这不起作用:
$this->redirect(array('action' => 'view', $this->Post->id)));
创建后读取模型数据的正确方法是什么?
【问题讨论】:
-
可能是因为您使用的是
saveAll()。尝试使用save()并找出$this->Post->id中的内容
标签: cakephp