title: How to insert multiple rows using cakePHP
body: <p>In the cakePHP project I'm building, I want to insert a defined number of identical records. These will serve as placeholders records that will have additional data added later. Each record will insert the IDs taken from two <code>belongs_to</code> relationships as well as two other string values.</p>
  
  <p>What I want to do is be able to enter a value for the number of records I want created, which would equate to how many times the data is looped during save.</p>
  
  <p>What I don't know is:</p>
  
  <ol>
  <li><p>how to setup a loop to handle a set number of inserts</p></li>
  <li><p>how to define a form field in cakePHP that only sets the number of records to create.</p></li>
  </ol>
  
  <p>What I've tried is the following: </p>
  
  <pre><code>function  massAdd() {
      $inserts_required = 1;
      while ($inserts_required &lt;= 10) {
          $this-&gt;Match-&gt;create();
          $this-&gt;Match-&gt;save($this-&gt;data);
          echo $inserts_required++;
      }
  
      $brackets = $this-&gt;Match-&gt;Bracket-&gt;find('list');
      $this-&gt;set(compact('brackets'));
  }
  </code></pre>
  
  <p>What happens is: </p>
  
  <ol>
  <li><p>At the top of the screen, above the doc type, the string <code>12345678910</code> is displayed, this is displayed on screen </p></li>
  <li><p>A total of 11 records are created, and only the last record has the values passed in the form. I don't know why 11 records as opposed to 10 are created, and why only the last records has the entered form data?</p></li>
  </ol>
  
  <p>As always, your help and direction is appreciated.</p>