我无法在相关表格中保存数据
我有桌子
ProductsTable
ProductsPricesTable
在ProductsTable
表格中,我宣布了一个像
public function initialize( array $config ) {
parent::initialize($config);
...
$this->hasMany('ProductsPrices');
}
并且在ProductsController的添加操作中,我有类似
的内容 if( $this->request->is('post') ) {
$this->Products->patchEntity( $entity, $this->request->data, [
'associated' => ['ProductsPrices']
]);
if( $this->Products->save( $entity ) ) {
....
....
}
}
,request->data
看起来像
[
'category_id' => '68',
'code' => '20',
'name' => 'Tagliatelle Bolognese',
'description' => 'mit Fleischsauce ',
'order' => '20',
'active' => '1',
'offered' => '0',
'productsprices' => [
(int) 0 => [
'size_id' => '80',
'price' => '7'
]
]
]
它只保存prodcts
表中的产品,但在products_prices表中没有保存任何内容。其结构如下
id | product_id | size_id | price | created | modified
有什么想法吗?