Welcome, Guest
Username: Password: Remember me

TOPIC: NewBie problem - cant get Foreign Key lookup to wo

NewBie problem - cant get Foreign Key lookup to wo 06 Feb 2014 18:30 #12142

  • mtifinn
  • mtifinn's Avatar
  • Offline
  • Junior Member
  • Posts: 20
  • Thank you received: 2
  • Karma: 0
I am a newbie to jCook and cannot figure out how to get the Combo box in a form to populate from a foreign key. I have created two tables, and created a foreign key field in 1 of them and linked to the other table.

I have created the views but all I get in the combo (select) box when editing is a single line - which defaults to 0.

Bizarrely if I enter a value into the combo box (a select box) I can get the correct foreign table values - so the tables are linked- but I can't seem to get the foreign key ids to appear so I can select ... and in any case I should not be able to type a value in a combo box?


Update - I just realised that the field in the form is a text field (which explains why I can type in it) and yet I have specified Combo Box. Any Ideas why it renders the wrong field type?

Later ...

Solved it. Deleted all the fields and redid everything and now it works .. ;)
Last Edit: 06 Feb 2014 19:11 by mtifinn. Reason: Solved
The administrator has disabled public write access.

NewBie problem - cant get Foreign Key lookup to wo 06 Feb 2014 21:59 #12143

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
@mtifinn,

Glad you got it sorted!

For future reference and to avoid having to start over:
When you add your FK fields to layouts, ensure that you select and drag a child-node/element of the field to the layout and not the parent node/element.
Example: Basic Book Library
1. Create the following tables & fields:
1.1 Table 1: 'authors'
1.2 Table 1 Fields: 'id' (cook auto-created), 'name'
1.3 Table 2: 'books'
1.4 Table 2 Fields:
2. Create a new admin item layout for authors & drag the 'name' field to the layout
3. Create a new admin item layout for books & drag the 'title' field to the layout.
4. Click the + symbol of the 'author_id' field
5. Drag the 'name' (i.e. the author's name or authors.name) node to the layout NOT the 'author_id' node

I hope this helps in your future endeavours!

Best wishes,

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
Last Edit: 06 Feb 2014 22:00 by JoomGuy.
The administrator has disabled public write access.
The following user(s) said Thank You: admin, mtifinn

NewBie problem - cant get Foreign Key lookup to wo 06 Feb 2014 22:02 #12144

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
***ADD
Naturally, the same principle applies to displaying data in grid/list views too.
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.
Time to create page: 0.092 seconds

Get Started