Adding new filter to module in admin panel?

edited February 2015 in News & Announcements
Sorry I am new to fuelcms and don't know how to use the guide yet.
I know fuelcms can add a new filter to module in admin panel.
how to do it?


  • edited 11:05AM
    ok I found that I can do it in this way:
    $config['modules']['Locations'] = array(
    'filters' => array(
    'parent_id' => array(
    'default' => 1,
    'label' => 'Parent',
    'type' => 'select',
    'options' => array(
    1 => 'United Kingdom',
    2 => 'United State'

    And I got these problems:
    1. options - can I retrieve the list in the db?
    2. where is the doc about this filter?
  • edited 11:05AM
    1. You can specify a model in your configuration like so:
    2. There isn't a great section in the documentation yet about filtering but this area in the tutorial talks some about it:
  • edited 11:05AM
    thanks for your information

    I am facing a new problem now. Just now I fail to create new record to database using fuelcms. All custom code have been commeted, only the basic code left now and I still cannot create record probably.

    Table and code shown as below:
    CREATE TABLE `zy_locations` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `location_name` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
    `location_iso3` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL,
    `location_country_id` int(11) DEFAULT NULL,
    `location_state_id` int(11) DEFAULT NULL,
    `location_province_id` int(11) DEFAULT NULL,
    `location_city_id` int(11) DEFAULT NULL,
    `location_parentid` int(11) DEFAULT NULL,
    `location_type` int(11) DEFAULT NULL,
    `currency_id` int(11) DEFAULT NULL,
    `route_name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
    `createDate` datetime DEFAULT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `id_UNIQUE` (`id`),
    UNIQUE KEY `routeName_UNIQUE` (`route_name`)

    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');


    class Locations_model extends Base_module_model {

    // public $foreign_keys = array('location_type' => 'location_types_model',
    // 'currency_id' => 'currencies_model');

    function __construct()


    class Location_model extends Base_module_record {


    I have really no idea whats happening....
  • edited 11:05AM
    aiya, it actually saved my form data. It replace the exisiting record instead of inserting a new one. I am wonder why it run update instead of insert. Just a very simple action....
  • edited 11:05AM
    I'm curious why you have a unique key for ID when the primary key is already unique. Also, is the route_name you are saving different between the records (if left empty then it probably isn't)? FUEL's save command's default behavior is to try an insert with INSERT IGNORE but if if it runs into a key collision it does ON DUPLICATE KEY UPDATE. To avoid unique key issues there is $unique_fields property you can set on your model. The value should be an array listing any unique fields. If there is a compound key (multiple fields), you can use an array inside that array.
  • edited 11:05AM
    woot yeat!
    it work again, thanks for the advice
Sign In or Register to comment.