Jump to content


Category - Sub Category display

Category - Subcategory

  • Please log in to reply
No replies to this topic

#1 Sonelal Singh

Sonelal Singh

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 22 September 2015 - 03:17 AM

I have a question on previous forum(mentioned below)

http://www.grocerycr...-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.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users