⚠ 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

set_relation 1-n shows only data from the first table



mgr_metal
  • profile picture
  • Member

Posted 18 May 2012 - 05:11 AM

Hi,

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:

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

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

And my code below:


$this->grocery_crud->set_model('Category');

$this->grocery_crud->set_table('categories');
$this->grocery_crud->columns('id_category', 'name', 'link', 'ordr' );
$this->grocery_crud->set_subject("KateogiÄ™");
$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->callback_field('id_parent',array($this,'parent_select'));

$this->grocery_crud->unset_texteditor('meta_description');
$this->grocery_crud->unset_texteditor('meta_keywords');

$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');



Thanks!