【发布时间】:2023-03-29 09:40:02
【问题描述】:
早安,
我有一个名为 ProjectRequirement 的模型,它属于 Project,所以 Project 有许多 ProjectRequirements
当我创建 ProjectRequirement 条目时,我使用了这种方法:
<?php
echo $this->Form->inputs(array(
'legend => false,
'fieldset' => false,
'ProjectRequirement.1.description' => ...
'ProjectRequirement.2.description' => ...
'ProjectRequirement.3.description' => ...
));
?>
我这样做是为了可以使用 saveMany() 方法同时保存多条记录。但是,当我想在同一个表单上再次编辑这些记录时,我看不到能够做到这一点。我保留了相同的字段命名结构,并尝试将数据设置如下:
<?php
$this->request->data = $this->ProjectRequirement->find('all', array('conditions' => ...));
?>
pr();显示正在返回记录,但它们没有填充表单字段。如果我删除数字并只有一个这样的字段:
<?php
echo $this->Form->inputs(array(
'legend => false,
'fieldset' => false,
'ProjectRequirement.description' => ...
));
?>
它工作正常。如何设置数据,以便在多个 inout 字段上设置来自 ProjectRequirement 的多个记录?还是不能?
重申:我在保存多条记录时没有问题,我在检索要显示的多条记录时遇到了问题。
问候, 西蒙
【问题讨论】:
标签: cakephp model associations cakephp-2.0