⚠ 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

Category - Sub Category display



Sonelal Singh
  • profile picture
  • Member

Posted 22 September 2015 - 03:17 AM

I have a question on previous forum(mentioned below)

/topic/303-extra-categories-and-subcategories-dropdown-list/

 

 

How can I use below code when we have to use category with multiple fields(for example editing/adding user info).

I have two tables(users and category) like below - 

  • "users" table have following  fields --->user_id,name,gender,category.
  • "category" table have following fields ---> id,category,parent_id

 

       $this->load->library('grocery_CRUD');
       $crud = new grocery_CRUD();
        $crud->set_theme('datatables');
        $crud->set_table('users');
        $crud->set_subject('Users');
        $crud->set_relation('category', 'categories', 'category');
 
       /* Add this customisation for parent_relation */
 
        $primary_id_field  = 'id';
        $table_name   = 'categories';
        $relation_field_name = 'parent_id';
        $parent_field   = 'parent_id';
        $title_field   = 'category';
        $title_display_as  = 'Select Categoria';
        $where    = array('stato'=>'1');//not required
        $same_table   = true; //not required, the default is false
        $this->set_parent_relation($primary_id_field,$table_name,$parent_field,$title_field,$crud,$title_display_as,$relation_field_name,$where,$same_table);       
        
        $output['output'] = $crud->render();

        $this->load->view('template', $output);

 

Here how can I populate category like post-1-0-41549700-1334271141_thumb.png  when I am using two tables.

 

 

 

Thanks in advance.