在将 Fisica 实体保存到数据库时,一直试图将数据保存到其他表中,因为我是 cakephp 的新手,现在似乎不可能,看过多个帖子、视频、文档,但似乎都没有。请有人帮我弄清楚这有什么问题。
我在实体之间的关系中发现了一个巨大的错误,现在它是这样的:Fisica属于Pessoa
FisicasTable.php 上的关联
$this->belongsTo('Pessoa')
->setForeignKey('id_pessoa')
->setJoinType('INNER')
->setClassName('Pessoas');
Fisicas 控制器
$fisica = $this->Fisicas->newEntity();
if ($this->request->is('post')) {
$fisica = $this->Fisicas->patchEntity($fisica, $this->request->getData(),['associated' => 'Pessoa']);
if ($this->Fisicas->save($fisica))...
Fisica add.ctp
<legend><?= __('Add Fisica') ?></legend>
<?php
echo $this->Form->control('nr_cpf');
echo $this->Form->control('dt_nascimento');
?>
<legend><?= __('Add Pessoa') ?></legend>
<?php
echo $this->Form->control('pessoa.vr_nome');
echo $this->Form->control('pessoa.nr_telefone');
echo $this->Form->control('pessoa.vr_email');
?>
我收到以下错误: 错误
我希望在向 Fisica add.ctp 提交新寄存器时将这段代码插入到两个表中。
慕神8447489