Adding a Category dropdown to an advanced module
I started working with FuelCMS a week ago, and now I'm trying to add the category feature to my module.
I added public $foreign_keys = array('category_id' => array(FUEL_FOLDER => 'fuel_categories_model')); at the top of my model class. It appears it is working as I now have a dropdown with my categories, however when I hit save the dropdown reverts back to the default "select one" option. I have no idea if the category was saved, and I don't see anything in the database as well.
Is there something I must do in the form_fields method?
Comments
My next question is about displaying the category name in the list display. Currently it'll just show the category_id. Can I do a join query in the list_items method?
function list_items($limit = NULL, $offset = NULL, $col = 'name', $order = 'desc', $just_count = FALSE) { $this->db->join('fuel_categories', 'fuel_categories.id = category_id', 'left'); $this->db->select('my_table.id fuel_categories.name as category, my_table.publish); return parent::data($limit, $offset, $col, $order, $just_count); }