title: cakephp multiple insert from a form
body: <p>I have a site in cakephp 2.2, and I have a form with many input type text with a value taken from a query.</p>
  
  <p>I want when I save with a submit button to create for every input text a new record into my table in my database.</p>
  
  <p>First of all I have make a query a simple find and put it into a variable(prop). I make a <code>foreach</code> and for every record that I have found I create an input text. But when I save I don't want to update but to create a new record into my table the value can be changed or not but I want to save each  input type. I have try something but create only one record with value of the last input text and not for all.</p>
  
  <p>My table have some field</p>
  
  <ul>
  <li>table name: <code>ingredient_properties</code></li>
  <li>model name: <code>IngredientProperty</code></li>
  <li>field: <code>id</code>, <code>ingredient_id</code>, <code>property_id</code>, <code>user_id</code>, <code>created</code>, <code>modified</code>.</li>
  </ul>
  
  <p>This is my view *add_prop.ctp*</p>
  
  <pre><code>echo $this-&gt;Form-&gt;create('Ingredient', array ('class' =&gt; 'form')); 
      echo'&lt;p&gt;ELENCO PROPRIETA\'&lt;/p&gt;';
      foreach($prop as $p){ 
          echo('&lt;p&gt;'.$p['Property']['PropertyAlias'][0]['alias']);
          echo $this-&gt;Form-&gt;input('IngredientProperty.ingredient_id', array ('type'=&gt;'hidden', 'value'=&gt;  $p['IngredientProperty']['ingredient_id'],'label'=&gt; false, 'id' =&gt; 'id'));
          echo $this-&gt;Form-&gt;input('IngredientProperty.property_id', array ('type'=&gt;'hidden', 'value'=&gt;  $p['IngredientProperty']['property_id'],'label'=&gt; false, 'id' =&gt; 'id'));
          echo $this-&gt;Form-&gt;input('IngredientProperty.value', array ('label'=&gt; false, 'id' =&gt; 'value_'.$p['IngredientProperty']['id'], 'name' =&gt; 'value_'.$p['IngredientProperty']['id'],'value'=&gt; $p['IngredientProperty']['value'], 'after' =&gt; '&lt;div class="message"&gt;Inserisci un valore&lt;/div&gt;'));
          echo('&lt;/p&gt;');
  }
  echo $this-&gt;Form-&gt;submit('Salva', array('id'=&gt;'add_prop'));
      echo $this-&gt;Form-&gt;end();
  </code></pre>
  
  <p>And this is my controller Ingredient.php (<code>Ingredient</code> has many <code>IngredientProperty</code> and <code>Property</code> has many <code>ingredientProperty</code>)</p>
  
  <pre><code>public function add_prop($alias) {
          if ($this-&gt;request-&gt;is('post'))
          {
              //SAVE
              if ($this-&gt;Ingredient-&gt;IngredientProperty-&gt;saveAll($this-&gt;request-&gt;data)){
                  $this-&gt;set('flash_element','success');
                  $this-&gt;Session-&gt;setFlash ('Proprietà aggiornate con successo.');
                  //$this-&gt;redirect(array('action'=&gt;'photo',$alias));
              }
              else{
                  $this-&gt;set('flash_element','error');
                  $this-&gt;Session-&gt;setFlash('Errore di salvataggio proprietà');
              }
          }   
          else{
              //QUERY TO RETRIEVE DATA
  
              $this-&gt;set('prop',$this-&gt;Ingredient-&gt;IngredientProperty-&gt;find('all', array('recursive' =&gt; 2,
                          'conditions' =&gt; array('IngredientProperty.ingredient_id' =&gt; $id))));
  
              $this-&gt;loadModel('Property');
              $this-&gt;set('prop_all',$this-&gt;Property-&gt;find('all'));
  
              $this-&gt;loadModel('Unit');
              $this-&gt;set('unit',$this-&gt;Unit-&gt;find('all'));
  
          }
      }
  </code></pre>