I'm trying to create a Yii ActiveForm that edits values from a list of objects, presented in a table.
The classes involved:
class ResultForm extends CFormModel {
/**
* @var array[Result]
*/
public $results; //Filled with an array of Result objects
}
class Result {
public $requiredArea;
}
My view:
<% $form = $this->beginWidget('CActiveForm'); %>
<table>
....
<% $rowCounter = 0; foreach($resultForm->results as $result): %>
...
<tr>
....
<td>
<!-- This doesn't work -->
<% $form->textField($resultForm,
"results[$rowCounter]->requiredArea") %>
<!-- Just displaying the value works -->
<%= $resultForm->results[$rowCounter]->requiredArea %>
</td>
...
</tr>
<% $rowCounter++; endforeach; %>
</table>
<% $this->endWidget(); %>
The text fields are rendered and Yii does not complain, but they do not contain the proper values.
Is there a way I can make this work, or is there a better approach of for iterating through an array of objects in a form?