如何在cakephp 3.6

时间:2019-04-08 14:49:13

标签: cakephp orm associations cakephp-3.x

我正在尝试使用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"
]);

0 个答案:

没有答案