Thursday, November 27, 2008

Re: saveField removes associations

AngeloZanetti wrote:
>
> Hi all,
>
> i have a $hasAndBelongsToMany relationship between 'clubs' and
> 'competitions'.
>
> Now when I create a 'competition' i can allocate many clubs to it and save
> it and it saves correctly.
>
> The default for any newly created item is active=0, so after adding I want
> to activate the competition and when doing this it deletes all the
> associations between all the newly created competitions and the clubs
> associated. Im not sure why this is happening:
>
> $this->Competition->saveField('active', '1');
>
> The competition model is defined as follows:
>
> var $hasAndBelongsToMany = array(
> 'Club' => array('className' => 'Club',
> 'joinTable' => 'competitions_clubs',
> 'foreignKey' => 'competition_id',
> 'associationForeignKey' => 'club_id',
> 'unique' => true,
> 'conditions' => 'Club.active = 1',
> 'fields' => '',
> 'order' => 'Club.name',
> 'limit' => '',
> 'offset' => '',
> 'finderQuery' => '',
> 'deleteQuery' => '',
> 'insertQuery' => ''
> )
> );
>
> where am I going wrong?
>
> thanks
> Angelo
>
>

Is there a possibility that the logic somewhere else could be causing this
problem? As its very strange...what else do you need me to post in order to
troubleshoot this problem?\

TIA

--
View this message in context: http://www.nabble.com/saveField-removes-associations-tp20656915p20714919.html
Sent from the CakePHP mailing list archive at Nabble.com.


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