title: CakePHP 2.1 : HABTM saveAssociated and keep exists data
body: <p>I have a little problem with saveAssociated and exists entries :(</p>
  
  <p><strong>Models:</strong></p>
  
  <p><em>Ingredient.php</em></p>
  
  <pre><code>&lt;?php
  
  class Ingredient extends AppModel {
  
      public $name = 'Ingredient';
      public $hasMany = array('IngredientsRecipes');
  
      public $hasAndBelongsToMany = array(
          'Recipe' =&gt;
              array(
                  'className'              =&gt; 'Recipe',
                  'joinTable'              =&gt; 'ingredients_recipes',
                  'foreignKey'             =&gt; 'ingredient_id',
                  'associationForeignKey'  =&gt; 'recipe_id',
                  'unique'                 =&gt; 'keepExisting',
                  'conditions'             =&gt; '',
                  'fields'                 =&gt; '',
                  'order'                  =&gt; '',
                  'limit'                  =&gt; '',
                  'offset'                 =&gt; '',
                  'finderQuery'            =&gt; '',
                  'deleteQuery'            =&gt; '',
                  'insertQuery'            =&gt; ''
              )
      );
   }
  </code></pre>
  
  <p><em>Recipe.php</em></p>
  
  <pre><code>&lt;?php
  class Recipe extends AppModel {
      public $name = 'Recipe';
      public $hasMany = array('IngredientsRecipes');
      public $hasAndBelongsToMany = array(
          'Ingredient' =&gt;
              array(
                  'className'              =&gt; 'Ingredient',
                  'joinTable'              =&gt; 'ingredients_recipes',
                  'foreignKey'             =&gt; 'recipe_id',
                  'associationForeignKey'  =&gt; 'ingredient_id',
                  'unique'                 =&gt; 'keepExisting',
                  'conditions'             =&gt; '',
                  'fields'                 =&gt; '',
                  'order'                  =&gt; '',
                  'limit'                  =&gt; '',
                  'offset'                 =&gt; '',
                  'finderQuery'            =&gt; '',
                  'deleteQuery'            =&gt; '',
                  'insertQuery'            =&gt; ''
              )
      );
  }
  </code></pre>
  
  <p><em>IngredientRecipe.php</em></p>
  
  <pre><code>&lt;?php
  class IngredientRecipe extends AppModel {
      public $name = 'IngredientsRecipes';
      public $belongsTo = array('Ingredient', 'Recipe');
  }
  </code></pre>
  
  <p><strong>Views:</strong></p>
  
  <p><em>View/IngredientsRecipes/add.ctp</em></p>
  
  <pre><code>&lt;?php echo $this-&gt;Form-&gt;create('IngredientRecipe'); ?&gt;
      &lt;?php echo $this-&gt;Form-&gt;input('Ingredient.ingredient', array('type' =&gt; 'text', 'label' =&gt; 'Ingredient')); ?&gt;
      &lt;?php echo $this-&gt;Form-&gt;input('Recipe.recipe', array('type' =&gt; 'text', 'label' =&gt; 'Recipe')); ?&gt;
      &lt;button type="submit"&gt;Save&lt;/button&gt;
  &lt;?php echo $this-&gt;Form-&gt;end(); ?&gt;
  </code></pre>
  
  <p><strong>Contollers:</strong></p>
  
  <p><em>IngredientRecipeController.php</em></p>
  
  <pre><code>&lt;?php
  class IngredientRecipeController extends AppController {
  
  public function add() {
      if ($this-&gt;request-&gt;is('post')) {
       if(!empty($this-&gt;request-&gt;data)) {
         $ingredients_comma_separated = explode(',', $this-&gt;request-&gt;data['Ingredient']['ingredient']);
         $recipes_comma_separated = explode(',', $this-&gt;request-&gt;data['Recipe']['recipe']);
         $recipes = array();
           foreach($ingredients_comma_separated as $ingredient){
           $recipes['Ingredient']['ingredient'] = trim($ingredient);
           foreach($recipes_comma_separated as $recipe){
           $recipes['Recipe']['recipe'] = trim($recipe);
          if ($this-&gt;IngredientRecipe-&gt;saveAssociated($recipes, array('deep' =&gt; true, 'validate' =&gt; 'first'))) {
              $this-&gt;Session-&gt;setFlash('Saved.');
              }
            }
          }
        } 
      }
    }
  }
  </code></pre>
  
  <p><strong>MySQL Tables:</strong></p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `ingredients` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `ingredient` varchar(250) NOT NULL,
    `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    UNIQUE KEY `ingredient` (`ingredient`)
  ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
  
  CREATE TABLE IF NOT EXISTS `ingredients_recipes` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `ingredient_id` int(11) NOT NULL,
    `recipe_id` int(11) NOT NULL,
    PRIMARY KEY (`id`)
  ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
  
  CREATE TABLE IF NOT EXISTS `recipes` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `recipe` varchar(250) NOT NULL,
    `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    UNIQUE KEY `recipe` (`recipe`)
  ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
  </code></pre>
  
  <p><strong>My Question:</strong></p>
  
  <p>How i can keep exists data in recipes &amp; ingredients fields and continue saving associated data in ingredients_recipes field ?</p>