title: In Yii, how can I have a form that loops through an array of objects?
body: <p>I'm trying to create a Yii ActiveForm that edits values from a list of objects, presented in a table.</p>
  
  <p>The classes involved:</p>
  
  <pre><code>class ResultForm extends CFormModel {
  
      /**
       * @var array[Result]
       */
      public $results; //Filled with an array of Result objects
  }
  
  class Result {  
      public $requiredArea;
  }
  </code></pre>
  
  <p>My view:</p>
  
  <pre><code>&lt;% $form = $this-&gt;beginWidget('CActiveForm'); %&gt;
  &lt;table&gt;
     ....
     &lt;% $rowCounter = 0; foreach($resultForm-&gt;results as $result): %&gt;
         ...
         &lt;tr&gt;
             ....
             &lt;td&gt;
                 &lt;!-- This doesn't work --&gt;
                 &lt;% $form-&gt;textField($resultForm,
                     "results[$rowCounter]-&gt;requiredArea") %&gt;
  
                 &lt;!-- Just displaying the value works --&gt;
                 &lt;%= $resultForm-&gt;results[$rowCounter]-&gt;requiredArea %&gt;
             &lt;/td&gt;
             ...
         &lt;/tr&gt;
         &lt;% $rowCounter++; endforeach; %&gt;
  &lt;/table&gt;
  &lt;% $this-&gt;endWidget(); %&gt;
  </code></pre>
  
  <p>The text fields are rendered and Yii does not complain, but they do not contain the proper values.</p>
  
  <p>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?</p>