filter dropdown

edited May 2012 in Modules
Hi,

I have this simple module:

$config['modules']['games'] = array(
'module_name' => 'Games',
'filters' => array(
'partners' => array('label' => 'Socio', 'type' => 'select')
)
);

As you can see, I added a filter. This filter eventually appear on top of the list, but it doesn't contain any option.
Is there a way to populate this dropdown from the model?

Thank you!

Comments

  • edited May 2012
    You'll have to add the options by in the module config like so:
    // to prevent the querying from happening outside of the admin if (defined('FUEL_ADMIN')) { $CI =& get_instance(); $CI->load->model('games_model'); $game_options = $CI->games_model->options_list(); } else { $game_options = array(); } $config['modules']['games'] = array( 'module_name' => 'Games', 'filters' => array( 'partners' => array('label' => 'Socio', 'type' => 'select', 'options' => $game_options) ) );
    This will be changed though in the next release to make it easier.
  • edited 8:58AM
    Perfect! but now the dropdown doesn't seem to do anything...
  • edited 8:58AM
    ok, got it! didnt hit the search button :)
  • edited 8:58AM
    Ok, I made a few changes to make it easier to deal with it:

    in fuel/modules/fuel/controllers/module.php:
    below line 322 and 369, add:

    if(method_exists($this->model, 'filters'))
    $this->filters = $this->model->filters($this->filters);

    then in you simple module model, add:

    function filters($filters = array()){
    $filters['demos'] = array(
    'label' => 'Demos',
    'type' => 'select',
    'options' => array('' => '', 1 => 1, 2 => 2, 3 => 3)
    );
    return $filters;
    }
  • edited 8:58AM
    I like that idea of being able to add that to the model as well.
Sign In or Register to comment.