mardi 25 octobre 2016

How to make checkbox in grocery crud?

I have some code in Codeigniter with grocery crud library. 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 ?

Thank you for anyone answer.




Aucun commentaire:

Enregistrer un commentaire