In Yii Play ground complex dynamic rows
i have foreach invalid error whats the meaning of $persons and $person
and how can i insert into database anybody help me
<div class="complex">
<span class="label">
<?php echo Yii::t('ui', 'Persons'); ?>
</span>
<div class="panel">
<table class="templateFrame grid" cellspacing="0">
<thead class="templateHead">
<tr>
<td>
<?php echo $form->labelEx(Person::model(),'firstname');?>
</td>
<td>
<?php echo $form->labelEx(Person::model(),'lastname');?>
</td>
<td colspan="2">
<?php echo $form->labelEx(Person::model(),'eyecolor_code');?>
</td>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4">
<div class="add"><?php echo Yii::t('ui','New');?></div>
<textarea class="template" rows="0" cols="0">
<tr class="templateContent">
<td>
<?php echo CHtml::textField('Person[{0}][firstname]','',array('style'=>'width:100px')); ?>
</td>
<td>
<?php echo CHtml::textField('Person[{0}][lastname]','',array('style'=>'width:100px')); ?>
</td>
<td>
<?php echo CHtml::dropDownList('Person[{0}][eyecolor_code]','',Lookup::items('eyecolor'),array('style'=>'width:100px','prompt'=>'')); ?>
</td>
<td>
<div class="remove"><?php echo Yii::t('ui','Remove');?></div>
<input type="hidden" class="rowIndex" value="{0}" />
</td>
</tr>
</textarea>
</td>
</tr>
</tfoot>
<tbody class="templateTarget">
<?php foreach($persons as $i=>$person): ?>
<tr class="templateContent">
<td>
<?php echo $form->textField($person,"[$i]firstname",array('style'=>'width:100px')); ?>
</td>
<td>
<?php echo $form->textField($person,"[$i]lastname",array('style'=>'width:100px')); ?>
</td>
<td>
<?php echo $form->dropDownList($person,"[$i]eyecolor_code",Lookup::items('eyecolor'),array('style'=>'width:100px','prompt'=>'')); ?>
</td>
<td>
<div class="remove"><?php echo Yii::t('ui','Remove');?>
<input type="hidden" class="rowIndex" value="<?php echo $i;?>" />
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div><!--panel-->
</div><!--complex-->