CakePHP SaveAll不工作

CakePHP SaveAll不工作,cakephp,cakephp-2.0,Cakephp,Cakephp 2.0,我似乎无法让我的编辑课正常工作。我的验证工作正常,当我点击编辑按钮后使用debug($this->data)时,所有显示的数据都是完美的,但不更新表 这是我的编辑课 public function edit($id = null) { if($this->request->is('get')) { $this->request->data = $this->Bookmark->read(null, $id); } else {

我似乎无法让我的编辑课正常工作。我的验证工作正常,当我点击编辑按钮后使用debug($this->data)时,所有显示的数据都是完美的,但不更新表

这是我的编辑课

public function edit($id = null) {
    if($this->request->is('get')) {
        $this->request->data = $this->Bookmark->read(null, $id);
    } else {
        if($this->Bookmark->saveAll($this->request->data)) {
            $this->Session->setFlash('The bookmark has been saved!');
            $this->redirect(array('action' => 'index'));
        } else {
            $this->Session->setFlash('The bookmark could not be saved. Please, try again.');
        }
    }
}
这里是风景

<?php

echo $this->Form->create('Bookmark', array(
    'action' => 'edit',
    'inputDefaults' => array(
        'class' => 'input-text'
    )
));
echo $this->Form->inputs(array(
    'legend' => false,
    'fieldset' => true,
    'Bookmark.title',
    'Url.url',
    'Bookmark.id' => array('type' => 'hidden'),
    'Url.id' => array('type' => 'hidden')
));
echo $this->Form->button('Edit');
echo $this->Form->end();

?>
    'Bookmark.id' => array('type' => 'hidden'),
    'Url.id' => array('type' => 'hidden')

不太清楚原因,但我在网上查看了一些其他编辑视图,并尝试了此方法,现在效果很好。

尝试以下页面:

在Cake 2.0.x中,您应该使用
$this->request->data
,尽管这可能不是问题所在。您还将看到,他们没有手动设置id,而是允许表单对他们进行设置


如果您按照书中的建议尝试,但仍然不起作用,请将您的新尝试作为对该问题的编辑发布。

每次我遇到这种情况都是因为验证错误。检查是否存在这样的验证错误

echo debug( $this->ModelName->invalidFields() );

我已经试过了,并多次阅读了那个文件。无论是否使用请求部分,结果都是相同的。当我删除$this->Bookmark->id=$id;表单停止预填充表单字段。我还应该补充一点,如果我使用save而不是saveAll,它将保存标题,但不会保存Url。SaveAll不保存任何内容。你不应该需要$id行-如果你需要,这是关于问题所在的第一条线索。无需在此重复。只需调试。