Skip to Content Skip to Menu

🌟 CB Editor Assistant 1.0.0 is here! Discover our new AI Joomla Plugin that wrote its story! (and this banner!)
Start at just $12.50/month* or 💸 save 30% with our 🛍️ Black Friday Intro Offer for your subscription's lifetime
🎉 Black Friday sale is here! Great savings on professional and developer memberships! Get 25% off now with code BLACK-FRIDAY-2024!

[SOLVED] Configuring dynamic related fields

  • ducky13
  • ducky13
  • OFFLINE
  • Posts: 15
  • Thanks: 3
  • Karma: 0
6 years 5 months ago - 6 years 5 months ago #305131 by ducky13
Hi,

I am not accustomed to SQL queries and I am lost.
I have 3 fields related to the same thing: [society_name] [society_code1] [society_code2]. I created a “local_societies” table with this 3 values ‘society’, ‘code1’, ‘code2’ and 2 additional values for ‘region’ and ‘country’, in the Joomla database.
At Registration and Profile Edit, I would like to automatically fill up the 2 last fields when selecting the society name in a drop-down list.

I got inspiration from what is explained in the Query Field tutorial about “States/City/Zip” for trying to solve my problem.
Here is what I did:

For field [society name]:
- Field Type: Query Drop Down (Single Select)
- Query: SELECT DISTINCT `region`, `country`, `society` FROM `local_societies` ORDER BY `region`, `country`, `society`
- Options: Value Column = society // Label Column = society // Group Column = Country
- Update on = (nothing)

For field [society_code1]:
- Field Type: Query Drop Down (Single Select) … (don’t realy need a dropdown there because I have only one code1 per society)
- Query: SELECT DISTINCT `code1` FROM `local_societies` WHERE `society`=`[society_name]` ORDER BY `code1`
- Options: Value Column = code1 // Label Column = code1 // Group Column = (nothing)
- Update on = [society_name]

For field [society_code2]:
- Field Type: Query Drop Down (Single Select) … (don’t realy need a dropdown there because I have only one code2 per society)
- Query: SELECT `code2` FROM `local_societies` WHERE `code1`=`[ society_code1]` AND `society`=`[ society_name]` ORDER BY `code2`
- Options: Value Column = code2 // Label Column = code2 // Group Column = (nothing)
- Update on = [society_name] + [society_code1]

The first step is working : I get my first dropdown with societies sorts by region and country.
But, after selecting a society, nothing is displayed in the 2 other dropdown fields.

Any suggestion ?
Thanks for your help !
Last edit: 6 years 5 months ago by krileon. Reason: Added [SOLVED] tag to subject

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48560
  • Thanks: 8292
  • Karma: 1445
6 years 5 months ago #305137 by krileon
Replied by krileon on topic Configuring dynamic related fields
Use CB Core Fields Ajax and its Update On functionality. The Update On functionality built into CB Query Field is a legacy (first test run of such usage) implementation and will be going away in next feature release.

Additionally you'd back quotes around your substitutions where you need to be using single quotes. Only use back quotes for column names and tables. Examples as follows.

Incorrect: `[society_code1]`
Correct: '[society_code1]'

Your 3rd query also has a space between [ and society that'll prevent the substitution from working.


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.

  • ducky13
  • ducky13
  • OFFLINE
  • Posts: 15
  • Thanks: 3
  • Karma: 0
6 years 5 months ago #305142 by ducky13
Replied by ducky13 on topic Configuring dynamic related fields
Ok ... everything works correctly now !
Thanks for your help !
Have a nice day !
The following user(s) said Thank You: krileon

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

Moderators: beatnantkrileon
Powered by Kunena Forum