cakephp 3.x 将数据保存到具有很多关系的 2 个表中时数据未保存

cakephp 3.x data not saving when Saving data into 2 tables with has many relation

我有两个 tables 客户和分支分支在它们之间有字段 client_id 关系我们客户有许多分支和分支属于用户,我的 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.'));
            }
        }
?>

但数据保存在客户端table但不在分支table请告诉我id应该做什么或者我的错误是什么 抱歉我的英语不好

如果客户hasHany分支你应该做

echo $this->Form->input('branches.0.branch_name');
echo $this->Form->input('branches.0.email');

阅读 manual 关于它的内容