model's foreign key select labels

edited November 2012 in Modules
hello everyone

ive been using codeigniter for a while, and fuel cms really great in that it could save so much time. but im having some issues with it.

im writing a simple model 'commercials' with a foreign key 'title' of model 'text' (so i could select a title from 'texts' and have it translated in the text model). Viewing from fuel admin, the commercials/edit page, i see the 'title' foreign key as a select box, but the labels are all '0' because its showing the wrong collumn. so how do i set it to use a different collumn in the foreign key select box?

Comments

  • edited 4:41AM
    Easiest way is to have the field you want as the text label next to the key field in your schema.
  • edited November 2012
    thanks but thats not exactly what i am looking for...
    i just changed the database collumn order and that helped with displaying the option label, and i just found out theres a 'display_field' setting in my_fuel_models! ok now i can see the right labels, without having to reorder collumns, but i would like to filter them too... maybe there's a function i can ovveride that collects these foreign key options?
  • edited November 2012
    I don't think your config display_field is helping you with the label. That's used for displaying the name of the 'thing' you're editing in the fuel header and when deleting etc.

    Just tested to be sure, with a numeric value as the second column and both display_field and default_col set to name, I still see the numeric column value as the select label.

    You can override the options list behaviour. You'll need to have an options_list() method in your model.
Sign In or Register to comment.