Welcome, Guest
Username: Password: Remember me

TOPIC: Subsequent selections in form

Subsequent selections in form 27 Aug 2012 15:12 #3315

  • pbianco
  • pbianco's Avatar
  • Offline
  • Senior Member
  • Posts: 47
  • Thank you received: 2
  • Karma: 1
Hi,
I am new to Cook and I am trying to design an application where I need the user makes two nested selections.
To better explain, I have two different tables: table A contains the first selection (for examples, names of countries) and table B contains the other value, whose selection is dependent on the result of the first selection (for example, names of towns), together with the joined reference to table A.
I would like to design a form where the user enters data into a third table; the form should first display a first checkbox where the user may select an item X from table A (for example, country Italy) and then, based on this selection, a second checkbox should be displayed containing only records in table B which are joined to item X (for example, all Italian towns recorded in the table).
How is it possible?
(I hope my explanation is clear enough, please let me know if not).

Thanks
The administrator has disabled public write access.

Re: Subsequent selections in form 31 Aug 2012 14:01 #3346

  • dares
  • dares's Avatar
  • Offline
  • Junior Member
  • Posts: 37
  • Thank you received: 4
  • Karma: 2
Hi pbianco,

Please watch demo on www.j-cook.pro/docs/demo and you will get answer on your question
73,
Miro

Cook saves your time and make your life easier.
The administrator has disabled public write access.

Re: Subsequent selections in form 31 Aug 2012 17:10 #3349

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Hi pbianco,

On this forum, we will use the term 'Nested', when A and B is the same table. I mean hierarchical.
I precise it to speak a common language, even if 'nested' can be understood in your example.

Well, let's say 'Groups'.
Once you have selected a Country, the list of Towns of this Country can appear.

This is possible with the builder.

In your form, instance your FK : Town. (select the label you want, for example Town > Name, because if you do not do it, only a number will be shown)

Then, open the properties of it and select GroupBy : Country.
This will show all your Towns, grouped by Country.

You can do better with Ajax.
Click the Ajax option, and see the result ;-)

Well, it is working only with selects in native, but you have only one word to change to convert it in radios.

TODO :
in your view.html.php collection files (Countries, Towns)
, function : displayAjax()

Find the generated html (uses JDom), and change the namespace of the select :
replace
JDom::_('html.form.input.select', array(...

To:
JDom::_('html.form.input.radio', array(...

Not tested, but sould work.

Enjoy JDom ;-)
Coding is now a piece of cake
Last Edit: 31 Aug 2012 17:13 by admin.
The administrator has disabled public write access.
The following user(s) said Thank You: pbianco
Time to create page: 0.072 seconds

Get Started