title: CakePHP: How to update multiple records at the same time with the Form helper
body: <p>On an edit page for the model Test I want to be able to update the "Questions.order" field on all of it's associated (by hasMany) questions from the same form.</p>
  
  <p>I've ready the <a href="http://book.cakephp.org/2.0/en/models/saving-your-data.html" rel="nofollow">Cake book chapter on saveMany()/saveAll()</a> in the book, and I'm using the <code>Model.0.field syntax</code> but I can't figure out how to tell CakePHP <em>which</em> record to corresponds to <em>which</em> input. Should the <code>#</code> in <code>Model.#.field</code> correspond to the question's id field? Here's what I'm currently doing:</p>
  
  <pre><code> echo $this-&gt;Form-&gt;create( 'Question', array('action'=&gt;'order'));
  
  $n = 0;
  foreach ($questions_array as $question) : ?&gt;
          &lt;?php echo $this-&gt;Form-&gt;input('Question.'.$n.'.order' ); ?&gt;
          &lt;?php echo $this-&gt;Form-&gt;input('Question.'.$n.'.id', array('type'=&gt;'hidden', 'value'=&gt;$question['Question']['id']) ); ?&gt;
          &lt;input type="submit" value="Save" /&gt;
  ...
  $n++;
  endforeach;
  $this-&gt;Question-&gt;Form-&gt;end();
  </code></pre>
  
  <p>The form submits and appears to save, but the updated <code>order</code> values do not correspond to the right question records. What am I doing wrong?</p>
  
  <p><strong>Update</strong>:</p>
  
  <p>Here is the <code>order</code> action in my controller:</p>
  
  <pre><code>public function admin_order() {
      $data = $this-&gt;request-&gt;data;
      $this-&gt;Question-&gt;saveAll($data['Question']);
      $this-&gt;Session-&gt;setFlash( "Order saved.");
      $this-&gt;redirect( $this-&gt;referer() );
  }
  </code></pre>