我在Codeigniter中有杂货crud库的代码。我想知道如何制作复选框并将复选框的值插入数据库。
这是我的代码。
$crud = new grocery_CRUD();
$crud->set_subject('Gallery');
$crud->set_table('cms_gallery');
$crud->columns('pic_id','title','pic','pic2','showcase_url','categories','order','status');
$crud->fields('pic_id','title','pic','pic2','showcase_url','order','categories','status');
$crud->set_relation('categories','fn_design_category','name');
$crud->field_type('pic_id','invisible');
// $crud->callback_after_upload(array($this,'create_resized_pic'));
$crud->callback_before_delete(array($this,'delete_pic'));
// ->callback_after_update(array($this,'log_user_after_update'));
$crud->required_fields('status','pic','pic2','categories');
$path = 'assets/uploads/gallery';
$thumb_path = 'assets/uploads/gallery/thumb';
if(!is_dir($path)) //create the folder if it's not already exists
{
mkdir($path,0755,TRUE);
}
if(!is_dir($thumb_path)) //create the folder if it's not already exists
{
mkdir($thumb_path,0755,TRUE);
}
$crud->set_field_upload('pic',$path);
$crud->set_field_upload('pic2',$path);
$crud->unset_print()->unset_export()->unset_jquery();
$output = $crud->render();
如何使categories
成为复选框并将复选框的值插入数据库?
感谢有人回答。
答案 0 :(得分:2)
你可以使用像$crud->field_type('yourfield','true_false');
这样的field_type,这会在你的数据库表中给你0或1