found the problem...
EventComment had a validation rule on event_id being numeric... seemed to
work when the relationship was defined as hasMany but fell over when it was
hasOne.

removed the validation rule (input never entered into a user form anyway),
and it seems to be working fine now.

thanks for your help, the array structure works a treat.....


On Sun, Aug 21, 2011 at 5:02 PM, WebbedIT <[email protected]> wrote:

> Difficult to call without seeing more of the source code.
>
> I assume you call a different function to save the EventComment as the
> one you've shown appears to be for saving EventTransaction, if this is
> a universal save method why does it's name reference Transactions?
>
> Does your debugger register that you are in fact looping through the
> full data array, do you have debug turned on in cake and is it
> attempting to run the save at all?
>
> HTH, Paul.
>
> On Aug 21, 3:58 am, Greg Skerman <[email protected]> wrote:
> > Ok that worked to a degree :)
> >
> > my array now looks like this:
> >
> > Array
> > (
> >     [1] => Array
> >         (
> >             [Event] => Array
> >                 (
> >                     [event_type_id] => 2
> >                 )
> >
> >             [EventTransaction] => Array
> >                 (
> >                     [inventory_type_id] => 2867
> >                     [amount] => 123123
> >                 )
> >
> >         )
> >
> >     [2] => Array
> >         (
> >             [Event] => Array
> >                 (
> >                     [event_type_id] => 3
> >                 )
> >
> >             [EventComment] => Array
> >                 (
> >                     [comment] => asdasd
> >                 )
> >
> >         )
> >
> > )
> >
> > And I'm throwing the whole thing against a function which does this:
> >
> >         function saveTransactionEvent($data) {
> >             foreach ($data as $row) {
> >                 Debugger::dump($row);
> >                 $this->saveAll($row);
> >             }
> >         }
> >
> > The first entry gets successfully saved, the second one doesn't even
> run..
> >
> > Both child models are bound to the Event model like this:
> >         $this->Event->bindModel(
> >                 array('hasOne' => array('EventTransaction',
> > 'EventComment')), false
> >                 );
> >
> > So they should be bound for the remainder of the request - but the
> > EventComment, and its parent event never get saved....
> >
> > I've scaffolded an EventComment controller, and that will write a
> > comment fine... any reason why its not working in this context?
> >
> >
> >
> >
> >
> >
> >
> > On Sun, Aug 21, 2011 at 4:09 AM, WebbedIT <[email protected]> wrote:
> > > A good related blog post from teknoid:
> >
> > >http://nuts-and-bolts-of-cakephp.com/2009/03/26/saveall-with-multiple.
> ..
> >
> > > --
> > > Our newest site for the community: CakePHP Video Tutorials
> > >http://tv.cakephp.org
> > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> > > others with their CakePHP related questions.
> >
> > > To unsubscribe from this group, send email to
> > > [email protected] For more options, visit this
> group
> > > athttp://groups.google.com/group/cake-php
>
> --
> 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
> [email protected] For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
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
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to