Actually I need to create lots of models at the same time, so I am using arrays.
The only trouble that I am having is that even when I change the ID of the text field, all the javascript that is made by yii, only includes the original id for that field, so if I create automatically all the fields for my model, and I change manually those fields ID, I can not get the validation to work on them.
If I don’t change the id of the fields I will have validation errors in all the fields with the same name.
I don’t know if I have been really clear, but is really probable that someone already did something like this.
This is the way that I am changing the id of the fields :
<?php
$numero = 0;
foreach ($productos as $producto) {
$numero++;
?>
<tr>
<td><?=$numero?></td>
<td><?= $form->field($producto, 'cantidad')->textInput(array(
'id' => 'productoscotizacion-cantidad-'.$numero
))
?>
This way each of the $models will have an uniqueid for each one of the attributed fields.