it doesn't work. :/


On 24 jan, 18:33, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I believe that whatever model you are using to save needs to be first
> in your array, so if you are saving with $this->Tab->save() your code
> needs to look like this:
>
>         $to_save['Tab'] = array(
>                                                 'title'         =>
> '(Onglet)',
>                                                 'position'      =>
> ($position['0']['0']['position']+1)
>                                         );
>        $to_save['Version'] = array(
>                                                         'id'    =>
> $this->data['Version']['id']
>                                                 );
>        $this->Tab->save($to_save, true);
>
> Or, you can use $this->Tab->Version->save($to_save) with your current
> setup instead.
>
> Also, If you are using Cake 1.2 you may be seeing this bug:
>
> http://groups.google.com/group/cake-php/browse_thread/thread/2ad48c4e...
>
> Try Nina's fix and see if it works.
>
> Dave
>
> On Jan 24, 9:11 am, LoKi <[EMAIL PROTECTED]> wrote:
>
> > Hi! I'm beginner with cakephp.
> > I have two objets linked with "hasAndBelongsToMany" association :
>
> > VERSION MODEL
> > *******************************************************************************************
>
> > class Version extends AppModel {
> >     var $name = 'Version';
>
> >     var $hasAndBelongsToMany= array('Tab' =>
> >                                                                    
> > array('className'    => 'Tab',
> >                                                                             
> >      'joinTable'    => 'tabs_versions',
> >                                                                             
> >      'foreignKey'   => 'version_id',
> >                                                                             
> >      'associationForeignKey'=> 'tab_id',
> >                                                                             
> >      'unique'       => true
> >                                                                    )
> >                                                                 );
>
> > }
>
> > TAB MODEL
> > *******************************************************************************************
>
> > class Tab extends AppModel {
> >     var $name = 'Tab';
>
> >     var $hasAndBelongsToMany= array('Version' =>
> >                                                                    
> > array('className'    => 'Version',
> >                                                                             
> >      'joinTable'    => 'tabs_versions',
> >                                                                             
> >      'foreignKey'   => 'tab_id',
> >                                                                             
> >      'associationForeignKey'=> 'version_id',
> >                                                                             
> >      'unique'       => true
> >                                                                    )
> >                                );
>
> > }
>
> > **********************************************************************************************************
>
> > I would like to make a new "tab" without form.
> > My problem : The new tab is created, but the association in the table
> > named "tabs_versions" (in database) isn't created.
>
> > My actual php code (in controller) :
>
> >         $to_save = array();
> >         $to_save['Version'] = array(
> >                                                         'id'    => 
> > $this->data['Version']['id']
> >                                                 );
> >         $to_save['Tab'] = array(
> >                                                 'title'         => 
> > '(Onglet)',
> >                                                 'position'      => 
> > ($position['0']['0']['position']+1)
> >                                         );
> >         $this->Tab->save($to_save, true);
>
> > How can I do ?
> > Thanks a lot!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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