I am working with two HABTM association. One is between models 'Item' and 'Label' and the other is between 'BalistikList' and 'Label'.
I am having no trouble working with the association between 'Item' and 'Label' because all naming in models and tables follows Cake conventions. Controller logic for the 'BalistikList' and 'Label' association is essentially the same as that of 'Item' and 'Label' but Model::save() does not work. This leads me to believe my models must be wrong in the case of the 'BalistikList' and 'Label' association... likely because the 'BalistikList' model uses 'lists' for its tables and 'list_id' for foreign keys. I've checked and double checked to make sure my HABTM keys are correct using http://book.cakephp.org/view/83/hasAndBelongsToMany-HABTM as a reference, but to no avail. My code is below. Can anyone clue me in on whether there are mistakes with the models? BalistikList model class BalistikList extends AppModel { var $name = 'BalistikList'; var $useTable = 'lists'; var $hasAndBelongsToMany = array( 'Label' => array( 'className' => 'Label', 'joinTable' => 'labels_lists', 'with' => 'LabelBalistikList', 'foreign_key' => 'label_id', 'associationForeignKey' => 'list_id', 'dependent' => true, ), ); } Label model class Label extends AppModel { var $name = 'Label'; var $hasAndBelongsToMany = array( 'Item', 'BalistikList' => array( 'className' => 'BalistikList', 'joinTable' => 'labels_lists', 'with' => 'LabelBalistikList', 'foreign_key' => 'list_id', 'associationForeignKey' => 'label_id' ) ); } And here is the join table CREATE TABLE IF NOT EXISTS `labels_lists` ( `id` int(11) NOT NULL auto_increment, `label_id` int(11) NOT NULL, `list_id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- View this message in context: http://n2.nabble.com/Creating-HABTM-associations-with-table-names-that-do-not-follow-Cake-conventions-tp1558730p1558730.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 [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 -~----------~----~----~----~------~----~------~--~---
