I have People belongsToMany Phones. Can I save a person with its phone in one save() like this?
in PeopleTable:
$this->belongsToMany('Phones', [
'foreignKey' => 'person_id',
'targetForeignKey' => 'phone_id',
'joinTable' => 'people_phones'
]);
in add.ctp:
$this->Form->create($person);
$this->Form->input('person_name');
$this->Form->input('phones.0.phone_number');
in PeopleController:
$person = $this->People->patchEntity($person, $this->request->data, ['associated' => ['Phones']]);
$this->People->save($person, ['associated' => ['Phones']])
But only the person gets saved, without the phone. No error message. Is it even possible to save it like this?
I have CakePHP 3.0.2 (updated today)
Mabye I should add that I'm a beginner, never coded in OOP before, and I tortured google for two days now without any relevant answer. Simply "yes, it should work this way, you must have some error there" or "no, you must save Phone first to get its ID" would be sufficient :) Thanks