⚠ 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



ELJUSTICEIRO

ELJUSTICEIRO
  • profile picture
  • Member

Posted 30 August 2013 - 17:49 PM

I need to make a relationship, but the field names are different
follow the example of my table

 

 

Table Category

id

code

nameCategory

 

Tabela Films

id

codeCategory

name

 

I need make a relationship with   codeCategory and code.

 

 

$crud->set_table('films');

$crud->set_relation('codeCategory','category','nameCategory');

 

don't work.

 

Help me please..

 

 


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 31 August 2013 - 08:37 AM

is there any javascript error that comes in ... or what ? what is the the exact problem? Are you not able to get value in list or you not getting a dropdown in form.. what is the issue exactly can you specify?


davidoster

davidoster
  • profile picture
  • Member

Posted 31 August 2013 - 09:38 AM

If I understand it correctly tell me if I am wrong,

 

films.codeCategory = category.code

 

and you want when the user selects a category.nameCategory to store the value of category.code to the database, right?


ELJUSTICEIRO

ELJUSTICEIRO
  • profile picture
  • Member

Posted 01 September 2013 - 18:06 PM

yes, that's exactly what I want

$ crud-> set_relation ('codeCategory', 'category', 'nameCategory');

How to put the relationship category.code


davidoster

davidoster
  • profile picture
  • Member

Posted 03 September 2013 - 12:39 PM

Well, for this you will need to make a custom model.

Check here some sample code I have posted a while back.