⚠ 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 issue



marioromero78

marioromero78
  • profile picture
  • Member

Posted 13 March 2012 - 20:58 PM

Hi! I've got an issue with set_relation method.

This my code...


public function pedidos()
{
$crud = new grocery_CRUD();
$crud->set_relation('idpedido_estado','pedidos_estados','nombre'); //This doesn't work
$crud->set_relation('idusuario','usuarios','username'); //This works great!
$crud->set_table('pedidos');

$output = $crud->render();

$this->_example_output($output);
}


It renders a table with 'idpedido_estado' field empty and 'idusuario' field ok.

I put a var_dump($this->relation) here .... 'grocery_CRUD_Model.get_list()' and I can only see one row, not two!

array(1) { ["idusuario"]=> array(3) { [0]=> string(9) "idusuario" [1]=> string(8) "usuarios" [2]=> string(8) "username" } }


I tried to figure it out, but I can't.
Can anyone help me?
Thank you!

Mario

marioromero78

marioromero78
  • profile picture
  • Member

Posted 20 March 2012 - 14:38 PM

Solved! It was my mistake. I'd forgot to set the primary key of some tables. It works great!
Sorry!

:)