CrimpJiggler Posted January 31, 2014 Share Posted January 31, 2014 I have 6 models connected with HABTM relationships, and on the edit and add pages for each one, I load a list of the other 5. For some reason whenever I try to get a list of "products" it gives me a list of "compounds". There are some glitches with the pagination pages and redirects and stuff and it seems to be the compounds model involved in all these glitches. Changing from $this->model1->Product to ClassRegistry::init('Product') doesn't change anything. Heres one of the HABTM relationships (for the compound model): public $hasAndBelongsToMany = array( 'SubstancesCategory' => array( 'className' => 'SubstancesCategory', 'joinTable' => 'substances_cat_rels', 'foreignKey' => 'compound_id', 'associationForeignKey' => 'substances_category_id', 'unique' => 'keepExisting', 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'finderQuery' => '', ), 'Plant' => array( 'className' => 'Plant', 'joinTable' => 'substances_inter_rels', 'foreignKey' => 'compound_id', 'associationForeignKey' => 'plant_id', 'unique' => 'keepExisting', 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'finderQuery' => '', ), 'Preparation' => array( 'className' => 'Preparation', 'joinTable' => 'substances_inter_rels', 'foreignKey' => 'compound_id', 'associationForeignKey' => 'preparation_id', 'unique' => 'keepExisting', 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'finderQuery' => '', ), 'Product' => array( 'className' => 'Compound', 'joinTable' => 'substances_inter_rels', 'foreignKey' => 'compound_id', 'associationForeignKey' => 'product_id', 'unique' => 'keepExisting', 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'finderQuery' => '', ), 'Ailment' => array( 'className' => 'Ailment', 'joinTable' => 'substances_inter_rels', 'foreignKey' => 'compound_id', 'associationForeignKey' => 'ailment_id', 'unique' => 'keepExisting', 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'finderQuery' => '', ) ); and heres the problem: I'm using the same controller for 5 of these models, and a seperate controller for categories. I can load the products page fine, its just when I try to load a list that it loads a list of compounds instead. is there anything you can recommend I try to diagnose or fix the issue? Link to comment https://forums.phpfreaks.com/topic/285832-diagnosing-why-cake-is-loading-the-wrong-model/ Share on other sites More sharing options...
CrimpJiggler Posted February 1, 2014 Author Share Posted February 1, 2014 I figured out what the problem was. I had one of the ClassName associations in a model mixed up. Link to comment https://forums.phpfreaks.com/topic/285832-diagnosing-why-cake-is-loading-the-wrong-model/#findComment-1467375 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.