我有3张桌子
子氛围
id |其他领域
餐厅分支
id |其他领域
restaurant_branches_sub_ambiences
id | restaurant_branch_id | sub_ambience_id
我正在添加restaurant_branches并希望保存关联
restaurantBranches / add.ctp
<?php echo $this->Form->control('sub_ambiences._id', ['options' => $subAmbiences,'label' => false, 'multiple' => 'multiple']); ?>
控制器中的add()函数
$restaurantBranch = $this->RestaurantBranches->patchEntity($restaurantBranch, $this->request->getData(), [
'associated' => 'SubAmbiences'
]);
$this->RestaurantBranches->save($restaurantBranch)
保存时我收到错误
Error: SQLSTATE[HY000]: General error: 1364 Field 'name' doesn't have a default value
INSERT INTO `sub_ambiences` (`created`, `modified`) VALUES (:c0, :c1)
请帮助