Want to show foreign key of foreign key in dropdown
- Single Page
Posted 04 June 2012 - 14:07 PM
I have a table called Programs. Programs has a foreign key called categoryID to the Categories table. I have a table called Campus_Programs. This has a foreign key to the Programs table. In my dropdown for Campus_Programs, I am already successfully showing the Program foreign key, and the value from the categoryID column on the Programs table. But what I want to show is the foreign value for that column.
A diagram might help:
Programs: (id, name, categoryID)
-------------------------------------------
1 | Cosmetology | 1
Categories (id, name)
--------------------------------------------
1 | Associate's Degree
Campus_Programs (id, campusID, programID)
------------------------------------------------------------
1 | 1 | 1
So when I edit Campus Program 1, in the 'ProgramID' dropdown I want to show Cosmetology - Associate's Degree instead of just Cosmetology. Right now I have it displaying Cosmetology - 1 (IE Cosmetology - categoryID) but I need to expand that categoryID to get the related value from the Categories table.
Hopefully Grocery CRUD can allow for this use case.
Posted 05 June 2012 - 02:49 AM
http://www.grocerycrud.com/documentation/options_functions/set_model
I never did get it to work for me Good Luck.
Posted 05 June 2012 - 13:22 PM