Jump to content

set_relation 1-n shows only data from the first table

set_relation view table

  • Please log in to reply
No replies to this topic

#1 mgr_metal



  • Members
  • Pip
  • 2 posts

Posted 18 May 2012 - 05:11 AM


I have a problem with set_relation. Output grid shows data only from the first table. How can i access data from the second table.
Also quite don't understand what is the third parameter of set_relation function.

Relation categories.id_category = categories_info.id_category

My tables:

- id_category primary key, AI
- id_parent
- module
- level
- ordr

- id primary key, AI
- id_category
- name
- text
- link
- lang
- meta_title
- meta_description
- meta_keywords

And my code below:


  $this->grocery_crud->columns('id_category', 'name', 'link', 'ordr' );
  $this->grocery_crud->display_as('link', 'URL');
  $this->grocery_crud->display_as('id_parent', 'Rodzic');
  $this->grocery_crud->display_as('name', 'Nazwa kategorii');
  $this->grocery_crud->display_as('text', 'Tekst');
  $this->grocery_crud->fields('name', 'id_parent', 'text', 'ordr', 'meta_title', 'meta_description', 'meta_keywords', 'level', 'module', 'link', 'lang');

  $this->grocery_crud->change_field_type('level', 'hidden');
  $this->grocery_crud->change_field_type('module', 'hidden');
  $this->grocery_crud->change_field_type('link', 'hidden');
  $this->grocery_crud->change_field_type('lang', 'hidden');

  $this->grocery_crud->callback_insert(array($this, 'insert_category'));


  $this->grocery_crud->set_relation('id_category', 'categories_info', 'id_category');

  $output = $this->grocery_crud->render();

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

And my second question is. How can i hide fields in add/eddit form from the second table. Grocery crud seems to hide
fields only from the first table.

This works:
  $this->grocery_crud->change_field_type('module', 'hidden');

But this not:
  $this->grocery_crud->change_field_type('link', 'hidden');

Strona prezentujÄ…ca drewniane place zabaw z atestem dla dzieci.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users