0

I have below 3 tables

sub-ambiences

id | other fields

restaurant-branches

id | other fields

restaurant_branches_sub_ambiences

id | restaurant_branch_id | sub_ambience_id

I am adding the restaurant_branches and want to save associations

in restaurantBranches/add.ctp

<?php echo $this->Form->control('sub_ambiences._id', ['options' => $subAmbiences,'label' => false, 'multiple' => 'multiple']); ?>

add() function in controller

$restaurantBranch = $this->RestaurantBranches->patchEntity($restaurantBranch, $this->request->getData(), [
            'associated' => 'SubAmbiences'
        ]);
$this->RestaurantBranches->save($restaurantBranch)

while saving I am getting error

Error: SQLSTATE[HY000]: General error: 1364 Field 'name' doesn't have a default value 
 INSERT INTO `sub_ambiences` (`created`, `modified`) VALUES (:c0, :c1)

please help

Pankaj Jarial
  • 71
  • 2
  • 8

0 Answers0