我有两个表clients和branchs,它们之间有字段client_id关系,我们clienthasMany branches和branch属于用户,我的clients/add中有以下代码。ctp视图文件
<?php
echo $this->Form->create($client);
echo $this->Form->input('name');
echo $this->Form->input('branch.0.branch_name');
echo $this->Form->input('branch.0.email');
echo $this->Form->input('profile_link');
?>
and my controller code isas follow
<?php
public function add() {
$client = $this->Clients->newEntity();
if ($this->request->is('post')) {
$client = $this->Clients->patchEntity($client, $this->request->data, [
'associated' => ['Branches']
]);
if($this->Clients->save($client)) {
$this->Flash->success(__('data has been saved.'));
} else {
$this->Flash->error(__('The data could not be saved. Please, try again.'));
}
}
?>
但是数据保存在客户机表中而不是分支表中,请告诉我我应该做什么或者我的错误是什么
对不起我英语不好