I ended up setting manually the data fields like this at the top of the form. The $data will be an array if you get a collection for the form edit page:
/**
* Custom code to be used for $form->setValues as an array from $data
* $valueData['data_key' . $index] = value
*/
if (isset($data[$i]) && is_array($data[$i])) {
$valArr = $data[$i];
} else {
$valArr = $data;
}
foreach ($valArr as $datakey => $dataitem) {
$valueData[$datakey . $i] = $dataitem;
}
The form fields were like this:
$fieldset->addField(
'start_date' . $i, 'text', array(
'label' => Mage::helper('payperrentals')->__('Start Date'),
'class' => 'required-entry startdate',
'name' => 'start_date' . $i,
'title' => $i
)
);
Then on the end of the form I set it with:
$form->setValues($valueData);
Finally on the controller saveAction I used something like this:
for ($i = 0; $i < $numberOfProducts; $i++) {
$reservationOrderItem = Mage::getModel('payperrentals/reservationorders')->load($entityid);
$reservationOrderItem->setStartTurnoverBefore(ITwebexperts_Payperrentals_Helper_Date::toMysqlDate
($turnoverAr['before']))
->setEndTurnoverAfter(ITwebexperts_Payperrentals_Helper_Date::toMysqlDate
($turnoverAr['after']))
->setQty($data['qty' . $i])
->setProductId($data['product_id' . $i])
->setStartDate($data['start_date' . $i])
->setEndDate($data['end_date' . $i])
->setProductType('reservation')
->setComments($data['comments' . $i]);
if ($entityid) {
$reservationOrderItem->setId($entityid);
}
$reservationOrderItem->save(); }