A fast improvement for the foreign keys on models

edited June 2015 in Share
Hi there, I would like to comment a little improvement which was useful for me:
In a model with foreign keys I added 'display_field' for the combo
public $foreign_keys = array('guest_key_id'=>array(FUEL_FOLDER => 'User_keys_model','display_field' => 'name') );

to make it work just go to MY_Model.php function form_fields() go to line (LINE 2806) and inside the if (!empty($this->foreign_keys)) we add:
$display_field = NULL;
in line 2826 we add
if (!empty($val['display_field'])) { $display_field = $val['display_field']; unset($val['display_field']); }
and replace $fields[$key]['options'] = $CI->$model->options_list(NULL, NULL, $where, $order);
$fields[$key]['options'] = $CI->$model->options_list(NULL, $display_field, $where, $order);

Thats all!


Sign In or Register to comment.