⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

How to add multiple checkboxes in grocery crud codeigniter and save them



Hemant Randive
  • profile picture
  • Member

Posted 05 September 2015 - 09:23 AM

This is my code,now i can only able to insert single value but i want more than one value to be inserted  
 
public function cms_category_selected() {
        $crud = new grocery_CRUD();
        $crud->set_theme('datatables');
        $crud->set_table('articles');
        $crud->set_subject('Article');
        $crud->display_as('article_id', 'Article ID')
                ->display_as('article_name', 'Article Name')
                ->display_as('article', 'Article')
                ->display_as('category_id', 'Category ID')
                ->display_as('article_image', 'Article Image')
                ->display_as('tags', 'Tags')
 
                ->display_as('created_date', 'Created Date');
        $crud->set_relation('category_id', 'cms_category', 'category_name');
        $crud->set_relation('type_id', 'cms_types', 'type_name');
         
        $crud->callback_edit_field('category_id', array($this, 'edit_category_field'));
        $crud->callback_add_field('category_id', array($this, 'edit_category_field'));
        $crud->callback_edit_field('tags', array($this, 'edit_tags_field'));
        $crud->callback_add_field('tags', array($this, 'edit_tags_field'));
 
        $crud->columns('article_id', 'article_name', 'category_id', 'type_id', 'created_date', 'tags','article_image');
        $crud->required_fields('article_name', 'article', 'category_id', 'type_id');
        $crud->set_field_upload('article_image', 'assets/uploads/articleImages');
            // $crud->callback_after_upload(array($this,'example_callback_after_upload'));
     
        $crud->fields('article_name', 'article', 'type_id', 'tags','article_image');
        $output = $crud->render();
        $this->_example_output($output);
    }
    
    public function wellness_cms_category_selected()
    {
        $crud = new grocery_CRUD();
        $crud->set_theme('datatables');
        $crud->set_table('articles');
        $crud->set_subject('Article');
        $crud->display_as('article_id', 'Article ID')
                ->display_as('article_name', 'Article Name')
                ->display_as('article', 'Article')
                ->display_as('category_id', 'Category ID')
                ->display_as('article_image', 'Article Image')
                ->display_as('tags', 'Tags')
 
                ->display_as('created_date', 'Created Date');
        $crud->set_relation('category_id', 'cms_category', 'category_name');
        $crud->set_relation('type_id', 'cms_types', 'type_name');
         
        $crud->callback_edit_field('category_id', array($this, 'edit_category_field'));
        $crud->callback_add_field('category_id', array($this, 'edit_category_field'));
        $crud->callback_edit_field('tags', array($this, 'edit_tags_field'));
        $crud->callback_add_field('tags', array($this, 'edit_tags_field'));
 
        $crud->columns('article_id', 'article_name', 'category_id', 'type_id', 'created_date', 'tags','article_image');
        $crud->required_fields('article_name', 'article', 'category_id', 'type_id');
        $crud->set_field_upload('article_image', 'assets/uploads/articleImages');
            // $crud->callback_after_upload(array($this,'example_callback_after_upload'));
     
        $crud->fields('article_name', 'article', 'type_id', 'tags','article_image');
        $output = $crud->render();
        $this->_example_output($output);
    }
 
 
 function edit_tags_field() {
  return  ' <input type="checkbox" name="tags" value="male" /> Male
  <input type="checkbox" name="tags" value="female" /> Female';
        
    }

 


Amit Shah
  • profile picture
  • Member

Posted 05 September 2015 - 13:21 PM

 you can refer to this url - it should help you out

http://www.grocerycrud.com/documentation/options_functions/field_type#set-field