0
我有兩個表客戶端和分支機構分支機構之間有字段client_id關係我們客戶端hasMany分支機構和分支機構屬於用戶,我在我的下面的代碼客戶/ add.ctp視圖文件cakephp 3.x數據沒有保存時,將數據保存到兩個表中有很多關係
<?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.'));
}
}
?>
,但保存在客戶表中的數據而不是在轉移表,請告訴我應該ID做什麼或什麼我的錯誤是 對不起我的英文不好
感謝兄弟公司解決了我的問題 –