我有一个包含多个模型的表格。1 个模型将显示 1 条记录,其他模型将以表格格式显示多条记录。当我提交保存时,我只得到每个模型的最后一条记录。如何获取模型的所有记录?
这是我如何在表单上呈现表格格式模型的示例
// lines tab
$lineListContent = "<div id='form_line_list'>
<table>
<tr>
<th>JOBNO</th>
<th>NAME</th>
<th>SEQ</th>
<th>DATEIN</th>
<th>DATEDONE</th>
<th>STATUS</th>
<th>PCENthONE</th>
<th>EARNED</th>
<th>VALUE</th>
<th>COMMENTS</th>
<th>SENTBACK</th>
<th>DATEDUE</th>
<th>ORIGTAPES</th>
</tr>
";
$lineListContentRows = null;
foreach ($jobs as $i=>$item){
$lineListContentRows = $lineListContentRows . $this->renderPartial('/jobs/_form', array('model'=>$item,'form'=>$form),TRUE);
}
$lineListContent = $lineListContent . $lineListContentRows . "
</table></div>";
for 循环获取其模型的输入字段
_形式
<?php
/* @var $this JobsController */
/* @var $model Jobs */
/* @var $form CActiveForm */
?>
<div class="form">
<tr>
<td><?php echo $form->textField($model,'JOBNO'); ?></td>
<td><?php echo $form->textField($model,'NAME'); ?></td>
<td><?php echo $form->textField($model,'SEQ'); ?></td>
<td><?php echo $form->textField($model,'DATEIN'); ?></td>
<td><?php echo $form->textField($model,'DATEDONE'); ?></td>
<td><?php echo $form->textField($model,'STATUS'); ?></td>
<td><?php echo $form->textField($model,'PCENTDONE'); ?></td>
<td><?php echo $form->textField($model,'EARNED'); ?></td>
<td><?php echo $form->textField($model,'VALUE'); ?></td>
<td><?php echo $form->textField($model,'COMMENTS'); ?></td>
<td><?php echo $form->textField($model,'SENTBACK'); ?></td>
<td><?php echo $form->textField($model,'DATEDUE'); ?></td>
<td><?php echo $form->textField($model,'ORIGTAPES'); ?></td>
</tr>
</div><!-- form -->