Jump to content

via Ad Packs

Using set_relation


  • Please log in to reply
3 replies to this topic

#1 Brian Humes

Brian Humes

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 20 August 2012 - 08:13 PM

Obviously, I'm using set-relation incorrectly, but I can't figure out what I'm doing wrong.

I have two tables, products and categories.

Products table looks like this:
- id
- productName
- category_id

Categories table looks like this:
- id
- category_name

My function looks like this:

function products()
{
	$crud = new grocery_CRUD();
	$crud->set_theme('datatables');
	$crud->set_table('products');
	$crud->set_subject('Store Products');
	$crud->set_relation('category_id','categories','category_name');
	$output = $this->grocery_crud->render();
  
	$this->load->view('admin/crud',$output);
}

But when I load either the list or edit view, I am only seeing the category ID number. No dropdowns, etc.

Any help would be greatly appreciated! Thanks!

#2 noskov

noskov

    grocery CRUD Guru

  • Advanced Member
  • PipPipPip
  • 175 posts
  • LocationKiev

Posted 20 August 2012 - 08:27 PM

Hi, Brian Humes and welcome to the forum!
Try to change these lines:
$output = $this->grocery_crud->render();
$this->load->view('admin/crud',$output);

into these:
$output = $crud->render();
$this->_example_output($output);

P.S. Have you got any errors at the firebug?

#3 Brian Humes

Brian Humes

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 21 August 2012 - 11:58 AM

That did it! Working perfectly now.

You, sir, are a gentleman and a scholar. Thank you for your assistance.

#4 noskov

noskov

    grocery CRUD Guru

  • Advanced Member
  • PipPipPip
  • 175 posts
  • LocationKiev

Posted 21 August 2012 - 01:47 PM

You are welcome ;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users