inconsistent behaviour and I should raise a ticket?
cheers
On Apr 22, 7:26 pm, Tonu Tusk <lvot...@googlemail.com> wrote:
> Hi there ...
>
> so let's say I have
>
> Cake habtm Ingredient
>
> and
>
> Ingredient habmt Cake
>
> If I was to prep $data such as
>
> [Cake][id] => 1
> [Ingredient] => array(1, 2, 3)
>
> and did a
>
> Cake->save($data)
>
> this would delete any existing associating records in the join table
> between these two models and
> then associate Ingredients with id 1,2,3 to Cake record with id 1 ...
>
> To save on code, I am trying to spit the contents of my form generated
> posted data array
> straight to a model, but am not sure how to handle it if the
> associated model data is empty.
>
> (i.e where originally I had Ingredients 1,2,3 associated with Cake id
> 1, I would just want to
> feed some data back so that a simple Cake->save($data) would delete
> the existing associations.
>
> I have tried
>
> [Cake][id] => 1
> [Ingredient] => null
>
> and
>
> [Cake][id] => 1
> [Ingredient] => array()
>
> but it just retains the currently stored associations.
>
> I know I can catch a lack of associated Ingredients in the controller
> and manually delete the
> related records in the join table, but I would like to know if there
> is an easier (well less code) way of doing this as sugested above?
>
> cheers
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment