CakePHP 3 不保存关联?

CakePHP 3 Not Saving Associations?

好的,所以我会给我以下 $this->request->data 输出,

'editions' => [
    'title' => 'edtionTest',
    'active' => '0',
    'timestamp' => (int) 1438342639
    'articles' => [
        (int) 0 => [
            'picinfo_id' => '1',
            'image' => '/img/test222.jpeg',
            'title' => 'test222',
            'maintxt' => 'Donec diam tortor, ullamcorper non,....'
        ],
        (int) 1 => [
            'picinfo_id' => '2',
            'image' => '/img/TEST-NEW.jpeg',
            'title' => 'TESTING_AGAIN',
            'maintxt' => 'Donec diam tortor, ullamcorper non......'
        ]
    ],
]

然后我尝试获取 table 并保存,

$GetTable = TableRegistry::get('Editions');
$NewED = $GetTable->newEntities($this->request->data(),['associated' => ['Articles']]);

debug( $GetTable->save($NewED) );

而我的调试,return出现以下错误,

Argument 1 passed to Cake\ORM\Table::save() must implement interface Cake\Datasource\EntityInterface, array given,

我不认为这与我的模型有任何关系。据我所知,我已按照文件进行操作,但不确定我做错了什么?


编辑

如果我这样做,

 $NewED = $GetTable->newEntity($this->request->data); 

我得到一个 return 错误,但是当我这样做时,

 $NewEd = $GetTable->newEntity($this->request->data['editions']);

效果很好,它保存了,但似乎只保存了版本数据,与相关文章无关。

欢迎大家帮助。谢谢。

好的,不确定这是否是最好的方法,但我再次浏览了文档并重新阅读了所有内容。

只有当你循环输入时它才有效,

$NewEds = $GetTable->newEntities($this->request->data());

foreach ($NewEds as $NewKey => $NewValues) {
   $GetTable->save($NewValues);
}

似乎如果您已经完成了 'join' 个表格,那么您似乎不必 associated