Thursday, October 29, 2009

Re: Saving data to three models from one form

I'm not sure that's totally correct as I'm using saveAll quite
successfully in another part of the site to create new records in two
different models. The Chapter and Path models in fact - the code I'm
using for this new feature is based on it.

On Oct 28, 5:15 pm, Miles J <mileswjohn...@gmail.com> wrote:
> If you are saving date for the first time (inserting), you cannot use
> saveAll. The foreign keys and relations will not be set. This only
> works for updating, and when you do an update the IDs need to be
> hidden in the form somewhere.
>
> You need to do it like so:http://book.cakephp.org/view/75/Saving-Your-Data#Saving-Related-Model...
>
> On Oct 28, 10:04 am, Daniel <theworldof...@gmail.com> wrote:
>
> > I am using saveAll:
>
> > if ($this->Story->saveAll($this->data, array('validate' =>
> > 'first'))) // passed validation and successfully saved
>
> > Unless you mean without the array('validate' => 'first') - in which
> > case the validation only works for the Story model.
>
> > On Oct 28, 4:58 pm, Celso <cels...@gmail.com> wrote:
>
> > > Use saveAll
>
> > > On 28 out, 13:19, Daniel <theworldof...@gmail.com> wrote:
>
> > > > Hi guys, I've got a bit of a problem. Rather than type it all out
> > > > again here, is it OK if I just link to my blog with all the info:
>
> > > >http://theworldofdan.co.uk/2009/10/28/problem-saving-data-to-three-mo...
>
> > > > I would really appreciate it if someone is able to help me out with
> > > > this. Thank you
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: