Skip to content

Commit

Permalink
added ability to set an order parameter for the options list generate…
Browse files Browse the repository at this point in the history
…d by the foreign keys
  • Loading branch information
David McReynolds committed Dec 19, 2013
1 parent 677f182 commit 70883a9
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions fuel/modules/fuel/core/MY_Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 70883a9

Please sign in to comment.