saveAll and update issue across multiple models

View: New views
3 Messages — Rating Filter:   Alert me  

saveAll and update issue across multiple models

by appel268576 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi there.

I have a bit of an issue.
I am working on creating a post model that handles multiple postmeta
data for easily creating scalable forms.

I have the two models

post:

var $hasMany = array('Meta' =>
                array('className' => 'Meta',
                        'foreignKey' => 'post_id',
                        'order' => 'Meta.id ASC',
                        'dependent' => true,
                        'unique' => true,
                        'recursive' => '1'
                )
        );

I find it works fine when i create a new post with any amount of meta
fields set in the form.

When i delete the post it deletes all the meta information which is
perfect.

However when I update the information, instead of making use of the
previous information, it creates and saves new information to the
database...

Where I am going wrong?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: saveAll and update issue across multiple models

by robustsolution :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Dear appel268576,

It seems your edit form does not include the id of each child record,
that is why when you submit, new records are creating as if you are in
create mode!!!

have a nice baking day
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: saveAll and update issue across multiple models

by appel268576 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi robustsolution.

So If I just include the id's for each field it should solve the
problem?

On Nov 2, 2:44 pm, robustsolution <i...@...> wrote:
> Dear appel268576,
>
> It seems your edit form does not include the id of each child record,
> that is why when you submit, new records are creating as if you are in
> create mode!!!
>
> have a nice baking day

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---