From 70883a91ceeb9e1907f0ea0629d913d8f861bc75 Mon Sep 17 00:00:00 2001 From: David McReynolds Date: Wed, 18 Dec 2013 16:57:40 -0800 Subject: [PATCH] added ability to set an order parameter for the options list generated by the foreign keys --- fuel/modules/fuel/core/MY_Model.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/fuel/modules/fuel/core/MY_Model.php b/fuel/modules/fuel/core/MY_Model.php index 5a35d5ba1..9870eca6d 100755 --- a/fuel/modules/fuel/core/MY_Model.php +++ b/fuel/modules/fuel/core/MY_Model.php @@ -2700,14 +2700,23 @@ public function form_fields($values = array(), $related = array()) foreach($this->foreign_keys as $key => $val) { $where = array(); + $order = TRUE; $model = $this->load_model($val); - if (is_array($val) AND !empty($val['where'])) + if (is_array($val)) { - $where = $val['where']; - unset($val['where']); + if (!empty($val['where'])) + { + $where = $val['where']; + unset($val['where']); + } + if (!empty($val['order'])) + { + $order = $val['order']; + unset($val['order']); + } } $fields[$key]['type'] = 'select'; - $fields[$key]['options'] = $CI->$model->options_list(NULL, NULL, $where); + $fields[$key]['options'] = $CI->$model->options_list(NULL, NULL, $where, $order); $fields[$key]['first_option'] = lang('label_select_one'); $fields[$key]['label'] = ucfirst(str_replace('_', ' ', $CI->$model->singular_name(FALSE))); $fields[$key]['module'] = $CI->$model->short_name(TRUE, FALSE);