$ fieldList不保存cakephp中子表的数据

时间:2014-04-01 10:43:47

标签: cakephp

当我在Post和Comment表中保存数据而不传递$ fieldList时

$this->Post->saveAll($this->request->data, array('deep' => true, 'validates'=>true)))

它正在工作,但是当我传递$ fieldList时

$this->Post->saveAll($this->request->data, array('fieldList' => $fieldList, 'deep' => true, 'validates'=>true)))

数据已保存在父表中但在输入的子表空白记录中。 如何使用fieldList

在两个表中保存数据

1 个答案:

答案 0 :(得分:1)

这来自书:

$this->SomeModel->saveAll($data, array(
    'fieldList' => array(
        'SomeModel' => array('field_1'),
        'AssociatedModel' => array('field_2', 'field_3')
    )
));

所以我认为你在数组中缺少模型名称。