[英]How to make checkbox in grocery crud?
I have some code in Codeigniter with grocery crud library. 我在带有杂货杂货库的Codeigniter中有一些代码。 I want to know how to make checkbox and insert the value of checked checkbox into database.
我想知道如何制作复选框并将选中的复选框的值插入数据库。
This is my code. 这是我的代码。
$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();
How to make categories
become checkbox and insert the value of checked checkbox to database ? 如何使
categories
成为复选框,并将选中的复选框的值插入数据库?
Thank you for anyone answer. 谢谢任何人的回答。
you can use field_type like $crud->field_type('yourfield','true_false');
您可以像
$crud->field_type('yourfield','true_false');
这样使用field_type $crud->field_type('yourfield','true_false');
this will give you either 0 or 1 in your database table 这将在数据库表中给您0或1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.