CodeIgniter + Grocery Crud - how to set fields to either on/off (bool, checkbox) and also how to set it to be a select dropdown of numbers (1-10) ?
I have grocerycrud set up, and on some fields they are either:
bool values (but set as ints or varchars so groceycrud shows it as a
or
select dropdown with values 0-10 (these are stored as ints, but it is for a rating system)
any ideas?
thanks
For this you can check field_type method. In your case you need:
field type true_false for on/off boolean. For example:
$crud->field_type('my_field','true_false');
The default on/off for grocery CRUD is active/inactive (1/0) but you can change the text from the lang file at: assets/grocery_crud/languages/english.php (or your language) to on off.
For the second scenario of dropdown list you can use the field_type with type "dropdown" or "enum". For more you can go to: http://www.grocerycrud.com/documentation/options_functions/field_type#dropdown-field and http://www.grocerycrud.com/documentation/options_functions/field_type#enum-field that also have examples.
Also consider that the dropdown type is available only for versions >= 1.3.2