Foreign key name in table list.

Hi again, admin!

I have this problem:

I'v added public $foreign_keys = array('blog' => array(FUEL_FOLDER => 'blog_model'));
and i can select the foreign values, but when i look on the rows list i can see the value(foreign id), but no the displayed name.

Screenshot:

https://i.gyazo.com/619b7b5b63b05587191fd0b6d40c6a0c.png

Thank you for help <3

Comments

  • edited 12:56PM
    When you say "rows list" are you meaning the list view for the module or are you meaning the dropdown select for that field? If it's a foreign key, I'd include an "_id" on the field name to help denote it's a foreign key ID
  • edited 12:56PM
    No, i meant not the dropdown select. It works fine.

    https://i.gyazo.com/f2bc7b6b7c804e9264e12c75e132b611.png

    When i select blog_id in dropdown select i expect to see the name of the blog in list (screenshot), but i see only id value (1,2,3) etc.

    I'v tried blog_id, but it doesnt work for me :(
  • edited 12:56PM
    That looks like you'll need to modify the model's list_items method and include a join on the blog table:
    public function list_items($limit = NULL, $offset = NULL, $col = 'id', $order = 'asc', $just_count = FALSE) { $this->db->join('blog', 'blog.id' = 'mytable.blog_id', 'left'); $this->db->select('id, blog.name....'); $data = parent::list_items($limit, $offset, $col, $order, $just_count); return $data; }
Sign In or Register to comment.