Skip to Content Skip to Menu

🌟Discover the Joomla AI Plugin that wrote its own story! - CB Editor Assistant 1.1now for Joomla 3, 4 & 5!
✍️ 5-Day Free Trial, then 🎯 save up to 30% with our 🛍️ Intro Offer (First 50 users, ends Dec. 31)
🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

Building a 'linked' query selection field.

  • cpaschen
  • cpaschen
  • OFFLINE
  • Posts: 328
  • Thanks: 42
  • Karma: 9
11 years 2 months ago - 11 years 2 months ago #235697 by cpaschen
I've got one query field (cb_parishmasterorg) that allows a user to select a 'master' record from TABLEA using this query:
Code:
SELECT  CONCAT(`org_name`, ' (', `org_city`, ',', `org_state`,')') AS listing, `org_id`, `org_country`, `org_name` FROM `cbdata_cmd_organization` WHERE `master_org_id`=0 ORDER BY `org_country`,`org_name`

OPTIONS | Label Column = org_id

(master records have a 'master_org_id' of 0)

I then have a 'slave' query field (cb_parishname) that should allow the user to select one of several sub entries that have their 'master_org_id' record set to match the item chosen from the first query field using this query:
Code:
SELECT  CONCAT(`org_name`,' (',`org_city`, ',', `org_state`,' ', `org_country`,')') AS display, `org_id`, `org_name` FROM `cbdata_cmd_organization` WHERE `master_org_id`='[cb_parishmasterorg]' ORDER BY `org_name`

(the second/slave field is set to hide until a selection is made on the first).

The first one is working but the second one is displaying ALL of the entries from the table - like the WHERE clause isn't being run.
I've tried every variation of the WHERE syntax that I can think of, but it either returns no options or all options.

I'm starting to wonder if the problem is that the actual value of cb_parishmasterorg field isn't set yet (until the record is saved).

Is there another way to use the cb query fields and allow the selection of one field to 'influence' the results in a following field?
Last edit: 11 years 2 months ago by cpaschen. Reason: Fixing code display/wrapping - easier to read

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48630
  • Thanks: 8307
  • Karma: 1446
11 years 2 months ago #235745 by krileon
Replied by krileon on topic Building a 'linked' query selection field.
Your first field doesn't have a value set yet so your WHERE statement is resulting in "WHERE `master_org_id` = ''". They need to save their profile before the value can be used in the query.

Is there another way to use the cb query fields and allow the selection of one field to 'influence' the results in a following field?

No.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

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

  • cpaschen
  • cpaschen
  • OFFLINE
  • Posts: 328
  • Thanks: 42
  • Karma: 9
11 years 2 months ago #235775 by cpaschen
Replied by cpaschen on topic Building a 'linked' query selection field.
I was afraid of that.

Let me rephrase my question then,

Is there ANY way to have a user select an option in one field based on what they selected in a previous field (using ANY CB tools)?

Like having the selection in a 'country' then only display selected 'states' based on that country selection.

This is needed in a registration form, so they can't save their profile between the first and second field.

I have the developer subscription so I'm OK using WHATEVER solution is available (or building custom actions,etc.).

(I can't be the only one that needs something like this on a registration form am I?)

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48630
  • Thanks: 8307
  • Karma: 1446
11 years 2 months ago #235779 by krileon
Replied by krileon on topic Building a 'linked' query selection field.
No, you can't chain fields together like that. That would require Ajax to redraw the edit display of a field, which currently is not available (although is doable if developed). This feature is planned, but I've no idea when I'll have the time to develop it, sorry.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

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

  • cpaschen
  • cpaschen
  • OFFLINE
  • Posts: 328
  • Thanks: 42
  • Karma: 9
11 years 2 months ago #235781 by cpaschen
Replied by cpaschen on topic Building a 'linked' query selection field.
OK ... then one last question ... is it possible to save the registration form midway during the registration process (maybe via an auto action) so that the first field data is saved, but still let the user continue entering data? (so that the 2nd field will see that selection?)

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

  • cpaschen
  • cpaschen
  • OFFLINE
  • Posts: 328
  • Thanks: 42
  • Karma: 9
11 years 2 months ago #235783 by cpaschen
Replied by cpaschen on topic Building a 'linked' query selection field.
Follow-up, if not possible (to save during registration) can it be done on the profile page - i.e. automatically save the users' profile after they change data in one field?

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

Moderators: beatnantkrileon
Powered by Kunena Forum