I'm trying for 3 days to make it work, already apply all i have seen on stack/forums/google. A subscribers habtm subrcriberlist and a subscriberslist can belongs to many subscribers.
/* Subscriber model*/
public $hasAndBelongsToMany =
array(
'Subscriberslists' => array(
'className' => 'Subscriberslist',
'joinTable' => 'subscribers_subscriberslists',
'foreignKey' => 'subscriber_id',
'associationForeignKey' => 'subscriberslist_id',
'unique' => true
)
);
/* Subscriberslist model*/
public $hasAndBelongsToMany =
array(
'Subscribers' => array(
'className' => 'Subscriber',
'joinTable' => 'subscribers_subscriberslists',
'foreignKey' => 'subscriberslist_id',
'associationForeignKey' => 'subscriber_id',
'unique' => true
)
);
Datas are formatted like indicated in all post i have seen :
array(
'Subscriberslist' => '1',
'Subscriber' => array(
'Subscriber' => array(
(int) 0 => '1',
(int) 1 => '2',
(int) 2 => '3'
)
)
Then i could not save my data in my join table. Cake only save new Subscribers. Here is my controller :
if (!$this->Subscriber->saveAll($this->request->data){ //error}else{//no error}
Could you tell me what I'm doing wrong ? Thanks