蛋糕php 3 |保存时belongsToMany错误

时间:2017-03-23 04:29:05

标签: associations cakephp-3.0 has-and-belongs-to-many

我有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)

请帮助

0 个答案:

没有答案