Toggle custom enum yes/no field in advanced module
The database table I'm working with uses the column 'blocked' as a boolean and I'm also using published.
It seems that Fuel recognizes 'active' and 'published' as fields that you can click to set to yes or no.
What I'm trying to do is get the same functionality for 'blocked', is there any way to achieve this?
Comments
1. The first is the list view table, where it allows you to toggle the item between a "yes" and "no" value. The toggle functionality in the list view is done by using a column formatter function to apply to that column. This is done around line 272 of the fuel/modules/fuel/controller/module.php controller. There is also some corresponding javascript in fuel/modules/assets/js/fuel/controller/BaseFuelController.js file on the tableCallback method around line 916.
2. The second is that in the form view, there is a button in the top button bar, that allows you to toggle between the to states. You can control what buttons appear in your module by changing the "item_actions" module configuration parameter in your fuel/application/config/MY_fuel_modules.php. In your case, you would need to create an "others" which is somewhat explained here:
http://www.getfuelcms.com/user_guide/modules/simple
3. The third, is that in the base_model_module, the model that most model's inherit from, there is a _common_query() method that will automatically exclude those values with a published or active state of "no" are excluded from the query results when viewing the live site. You could duplicate that functionality in your models _common_query() method (be sure to call the parent::_common_query() in your model)
Hope this helps.
public $boolean_fields = array('featured_product');
to my simple modules model class (e.g.application/models/Products_model, in my case)
And this gave me the desired functionality on Fuel 1.0 beta.
Great stuff!
Thanks
Guy