Use of $foreign_key in advanced modules
What's the best practice when it comes to implementing related models within advanced modules?
The tutorial in the user guide covers simple modules :
http://www.getfuelcms.com/user_guide/modules/tutorial#categories_to_articles But when i look at the Blog module code, the $foreign_key field is never used. Instead, there's a number of custom functions that achieve the same result.
The thing is, the code as shown in the tutorial doesn't really apply to advanced modules (as stated here
http://getfuelcms.com/forums/discussion/comment/174/#Comment_174 - even though i'm still unable to make this work for some reason...) and I'm not sure if I should keep on trying to understand why is it that the foreign_key field doesn't seem to work for me, or just do it like the blog module does...
Can you please shed some light?
Thanks!
Comments
public $foreign_keys = array('id_ads_categories' => array('ads' => 'ads_categories_model');
The foreign_keys model attribute was added after the blog was developed and some of that may just be because we never went back and changed it.
Adding foreign keys should do a couple things for you:
# Create a dropdown of the values you need to select from instead of a text field in the form_fields model method (see around line 1750 of MY_Model)
# Will auto load other models on record objects (see around line 2985 of MY_Model)
What is happening?