This post should be called so close yet so far.

I am having an issue with saveAll() in my edit method which I am
hoping you can help me with. For some reason that I cant determine
it's creating new records in both tables instead up updating them. I
am sure it's something goofy that I have missed. I would expect from
what I have read <a href="http://teknoid.wordpress.com/2008/08/01/
practical-use-of-saveall-part-1-working-with-multiple-models/
#comment-907">here</a> that saveAll would update not insert the
records.

class Recipe extends AppModel
{
        var $hasMany= array('IngredientList');
}

class IngredientList extends AppModel
{
        var $belongsTo = array('Recipe');
}

        function edit($id = null)
        {
                $this->Recipe->id = $id;
                $this->set_recipe_types();
                $this->set_ingredients();
                $this->set_measurement_types();

                $this->set('ingredient_list', $this->IngredientList->find('all',
array ('recipe_id' => $id)));

                if (empty($this->data))
                {
                        $this->data = $this->Recipe->read();
                }
                else
                {
                        if ($this->Recipe->saveAll($this->data))
                        {
                                $this->flash('Your recipe has been 
updated.','/recipes');
                        }
                }
        }

Thanks for any advice you can give.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to