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



nyambe
  • profile picture
  • Member

Posted 19 June 2012 - 03:39 AM

What field does set_relation use to build the relation? I see it works, but not sure if I can force that behavior.
example

set relation field1(id) tableB field3(name). This will show the names of tableB. This correct.


Does it use same name fields in both tables as a link point?

noskov.biz
  • profile picture
  • Member

Posted 19 June 2012 - 09:05 AM

Hi, nyambe!
As you know, in set_relation function you have to specify at least 3 parametres: actual field in this table, the related table and any field from the related table that you want to show (and not just primary key field). When you use set_relation function, grocery CRUD will automatically create a dropdown list based on the content of your field in the related table.

When the user choose something from that dropdown, grocery CRUD will use the primary key of the field in the related table. So the link point is not the sameness of name fields.

Please, read about set_relation at the docs section. I think web-johnny's explanation is more clear and undestandable then mine :)

nyambe
  • profile picture
  • Member

Posted 20 June 2012 - 13:44 PM

Thanks, I sort of figured it out. So in this table the id of the other table row gets written in the sync field. Great to know. Thanks

noskov.biz
  • profile picture
  • Member

Posted 20 June 2012 - 21:19 PM

You are welcome!