Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

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

  • pbianco
  • pbianco's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 47
  • Thank you received: 2
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

Please Log in or Create an account to join the conversation.

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

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.

Please Log in or Create an account to join the conversation.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
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
The following user(s) said Thank You: pbianco

Please Log in or Create an account to join the conversation.

Last edit: by admin.
  • Page:
  • 1
Time to create page: 0.055 seconds

I must say that I'm leaps and bounds ahead of where I would have other been with J2.5 with full thanks to the folks on this forum and specifically to Cook so you'll never hear me complaining.
gdpodesta (Forum)  

Get Started