我正在尝试使用cakephp中的关联将数据插入两个表中,但是还没有锻炼。
控制器:
$payment = $this->Payments->patchEntity($payment, $this->request->data, [
'associated' => [
'ChequeDetails'
]
]);
型号:Payments
$this->hasOne('ChequeDetails', [
'foreignKey' => 'payment_id'
]);
型号:ChequeDetails
$this->belongsTo('Payments', [
'foreignKey' => 'payment_id'
]);
查看模板:
echo $this->Form->input('cheque_details.cheque_no', [
'label' => false,
"class" => "span6 m-wrap",
"Placeholder" => "Cheque No"
]);