Advanced Modules w/ list_items enum filter

edited November 2011 in Modules
I've looked around the forum and can't find an answer ... probably not looking for the right thing.

Situation:
I have a table with an enum column of locale values. I want to be able to filter the items in list view by their value in the enum column. Ideally by passing an options_list as the filter. I know that I can manually add all the enum values to an array and add it to my modules config (*_fuel_modules.php) file, but I don't want to be managing to lists of values and I assume there is a better way to do this.

Thanks in advance for your help.

Comments

  • edited 6:24PM
    It sounds like you may need to pull the field information from your model. You can use the model's "field_info" method to get the fields enum options. I haven't tested this but you can try something like following in your MY_fuel_modules.php file perhaps near the top:
    $options = array(); if (defined('FUEL_ADMIN')) { $CI =& get_instance(); $CI->load->model('my_model'); $info = $CI->my_model->field_info('my_field'); $options = $info['options']; }
    I wrap the call in a conditional so that it will only load the database if you are in the FUEL admin.
    http://www.getfuelcms.com/user_guide/libraries/my_model/table_class_functions
  • Thanks for the response.

    I'm trying to get it to work as a filter and show up next to the search at the top. I'm trying to break down the Assets module because the "Asset Folder" drop down functions exactly how I want mine to. The part I'm have trouble with is pushing the drop down to the filters array.

    How should I go about overriding the assets module init values form the model?
  • I think I got it. I created a controller and extended the Module controller of the Fuel module. The example below simply overrides the filter array in $config['modules']['localization_translations'].

    require_once(FUEL_PATH.'/controllers/Module.php'); class Translations extends Module { function __construct() { parent::__construct(); } function items() { $this->filters['translation_locale']['options'] = array( 'foo' => 'bar', 'hello' => 'world' ); parent::items(); } }
Sign In or Register to comment.