Welcome, Guest
Username: Password: Remember me

TOPIC: displaying all associated fields.

displaying all associated fields. 31 Jul 2012 06:41 #2938

  • cefnllys
  • cefnllys's Avatar
  • Offline
  • Premium Member
  • Posts: 102
  • Thank you received: 5
  • Karma: 1
Ok so i have a component where you can set up a venue location by filling in all its details e.g name, location e.t.c. now i want to be able to associate rooms to that venue using a seperate table e.g. on the seperate table you create new room and there is a drop down foreign key of all the venues you select one and give the room a name and fill in its details and click save. ok all nice and easy so far. now on a seperate table/page i want to choose a venue from an fkey and for it to display all the rooms associated with that venue. any one able to help or at least point me in the right direction?
The administrator has disabled public write access.

Re: displaying all associated fields. 31 Jul 2012 14:16 #2939

  • arnar
  • arnar's Avatar
  • Offline
  • Junior Member
  • Posts: 20
  • Thank you received: 1
  • Karma: 0
You could use a filter, otherwise you can search for master detail form. Using a master detail form means you need to code outside of cook.
The administrator has disabled public write access.

Re: displaying all associated fields. 01 Aug 2012 09:36 #2947

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
You can use the filters to see them in a new page.


But if you want to obtain a single page with your main item (location), and your related items below (rooms), the best is to merge the two views in the same.

A little bit of code is required both in you VIEW file and TMPL files

TODO :
Create a layout displaying filtered rooms (by location)

TO CODE :
Extract from this layout all the code and merge it properly (copy & paste don't work) in your main layout (location)
Then, instead of using a filters, connect the value of the main item, to filter the model of your rooms
(model->addWhere(.....))

I explained this many times in the forum and it is a very nice exercice to understand your component.
(It is the very first step)

Try even to do it by yourself, following this map. Read the files and try to understand, it will save you a lot of time once you've got the concept. (VIEW and TMPL is the most easy part)

I hope it helps.

A documentation of Cook (and coding components) will start to be written after the V2.0.
For the moment, V1.x is a draft, so there is no-sense to write an obsolete documentation.
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.113 seconds

Get Started