foreign_keys does not display usable text (id displayed)

domdom
edited February 2014 in Bug Reports
Hi all,

Not sure this is a bug - I am trying to get the list_items to display something more useful than the foreign key IDs. I have been at it for what seems like ages.

I can see that form_fields seems to work (ie - it translates the potential IDs into text with a dropdown) but it is not happening for the list_items function.

Do I need to do something particular to do it? I am working in an advanced model and the foreign keys all relate to other models in the same advanced module.

All I have done so far is set the foreign_keys variable, anything else I should do?

Thanks in advance,
Dom

Comments

  • edited 12:59AM
    You will have to overwrite your list_items method and use active record to do any necessary joins and selects. Your select should include the id value you identify with each record.
    function list_items($limit = NULL, $offset = NULL, $col = 'post_date', $order = 'desc', $just_count = FALSE) { $this->db->select('my_table.id AS id, title, my_other_table.foreign_field, my_table.published', FALSE); $this->db->join('my_other_table', 'my_other_table.id = my_table.my_other_id', 'left'); $data = parent::list_items($limit, $offset, $col, $order, $just_count); return $data; }
  • domdom
    edited 12:59AM
    Ahh ok I get it.

    I might extend the base class to do this as I have a lot of these to do.

    I might write something that parses the $fields variable to prepare all the joins.
Sign In or Register to comment.