The following is what I have done in my application:
>
> <?php

$pt = array();

foreach($types as $t){

$temp = array();

$temp['type_id'] = $t;

array_push($pt , $temp);

}

//So the  $pt structure will look like: array( 0 => array('type_id',
> 'xxxxxxxx'), 1 => array('type_id', 'yyyyyyyy') );


> $data = array(

'Task' => array(

'name'=>$name,

),

'Taskstype' => $pt

);


> $this->Task->id=null;

$back = $this->Task->saveAll($data , array('validate'=>'first'));

$errors = $this->Task->invalidFields();


I have run into the same problem with yours before. Usually, the fail reason
of this is because there is a none empty field in your model that you forget
to fill. Besides these, I have no idea what's the fail reason of yours until
now.

On Mon, Jul 13, 2009 at 9:19 AM, James Brown <[email protected]>wrote:

>
> the complete models can be seen here:
> http://bin.cakephp.org/view/905658608
>
> I assume my models are defined correctly. With the following array
> structure I am able to save relations to records of "Substitution",
> that means an entry in the join table is made. But I am not able to
> save any data in the related record.
>
> Array
> (
>    [LearningAgreement] => Array
>        (
>            [comment] => this is a testfield in LearningAgreement
>        )
>
>    [Substitution] => Array
>        (
>            [Substitution] => Array
>                (
>                    [0] => 1           // 1 is the id of an existing
> "Substitution" record
>                )
>
>        )
>
> )
>
>
>
> Cheers
>
> On Jul 12, 4:31 pm, joshua <[email protected]> wrote:
> > The structure expected in saveAll is the same as yours, take the example
> in
> > cakebook<
> http://book.cakephp.org/view/75/Saving-Your-Data#Saving-Related-Model.>
> > .
> >
> >
> >
> > > Array
> > > (
> > >     [Article] => Array
> > >         (
> > >             [title] => My first article
> > >         )
> > >     [Comment] => Array
> > >         (
> > >             [0] => Array
> > >                 (
> > >                     [comment] => Comment 1
> > >                [user_id] => 1
> > >                 )
> > >        [1] => Array
> > >                 (
> > >                     [comment] => Comment 2
> > >                [user_id] => 2
> > >                 )
> > >         )
> > > )
> >
> > > $this->Article->saveAll($data);
> >
> > Can you post your LearningAgreement Model and Substitution Model here?
> >
> > On Sun, Jul 12, 2009 at 10:15 PM, James Brown <
> [email protected]>wrote:
> >
> >
> >
> >
> >
> > > invalidFields() did not bring up any information. Thank you anyway,
> > > joshua!
> >
> > > On Jul 12, 3:14 pm, joshua <[email protected]> wrote:
> > > > You can give a try to see if there is any invalid Field in it.
> > > > [CODE]
> > > > $errors = $this->LearningAgreement->invalidFields();
> > > > debug($errors);
> > > > [/CODE]
> >
> > > > On Sun, Jul 12, 2009 at 3:32 PM, James Brown <
> [email protected]
> > > >wrote:
> >
> > > > > My Models:
> > > > > LearningAgreement HABTM Substitution
> >
> > > > > the array I give to the $this->LearningAgreement->saveAll(...)
> method
> > > > > has the following structure
> >
> > > > > Array
> > > > > (
> > > > >    [LearningAgreement] => Array
> > > > >        (
> > > > >            [comment] => testing
> > > > >        )
> >
> > > > >    [Substitution] => Array
> > > > >        (
> > > > >            [0] => Array
> > > > >                (
> > > > >                    [comment] => test
> > > > >                )
> >
> > > > >        )
> >
> > > > > )
> >
> > > > > When I use saveAll(), a "LearningAgreement" record is created but
> not
> > > > > a "Substitution" record. I am not sure what array structure
> saveAll()
> > > > > expects because it is not documented at
> >
> > > > >
> http://book.cakephp.org/view/75/Saving-Your-Data#Saving-Related-Model.
> > > ..
> >
> > > > > Hanging on this problem for 12 hours now. Any help is appreciated.
> >
> > > > --
> > > > Thanks
> > > > Joshua
> > > > 5span Inc. <https://www.5span.com>
> >
> > --
> > Thanks
> > Joshua
> > 5span Inc. <https://www.5span.com>
> >
>


-- 
Thanks
Joshua
5span Inc. <https://www.5span.com>

--~--~---------~--~----~------------~-------~--~----~
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