我的模型是可以拥有多个电子邮件地址的用户。我可以通过以下方式查看它们:
<?php foreach ($user->email_addresses as $addresses): ?>
<tr>
<td><?= h($addresses->id) ?></td>
<td><?= h($addresses->email) ?></td>
</tr>
?>
我尝试使它们作为输入可编辑,但不起作用:
<?php foreach ($user->email_addresses as $addresses): ?>
<tr>
<td><?= $this->Form->control('addresses.id'); ?></td>
<td><?= $this->Form->control('addresses.email'); ?></td>
</tr>
?>
答案 0 :(得分:0)
<?php foreach ($user->email_addresses as $index=>$addresses): ?>
<tr>
<td>
<?= $this->Form->control('email_addresses.'.$index.'.id') ?>
<?= $this->Form->control('email_addresses.'.$index.'.email') ?>