Show unique entire in dropdown

By: Richard Marlowe | Asked: 11/24/2024
ForumsCategory: General questionsShow unique entire in dropdown
Richard Marlowe asked 1 month ago

Hello,

I hope this email finds you well. I am reaching out to seek your assistance with an issue we are experiencing.  

Details of the issue:
We have configured two forms as follows:

1. Form1 contains a single field for selecting a "Country."

2. Form2 includes two fields: A "Country" dropdown field dynamically populated from Form1. A "City" field where users can manually add cities.

The issue:

After adding a few cities in Form2, we noticed that the "Country" dropdown menu in Form2 begins to display duplicate country entries.

What we need:

I’m looking for a way to ensure the "Country" dropdown menu in Form2 only displays unique countries, regardless of how many cities are added.

If there are specific steps, settings, or adjustments required to achieve this, please let me know. Your guidance will be greatly appreciated.

Thank you in advance for your support.

2 Answers
Best Answer
Rob LeVineRob LeVine answered 1 month ago
I refer you to: Dynamic vs. Lookup for an explanation and frm_data_sort for a possible solution.
Richard Marlowe replied 1 month ago

Thanks Rob, this is what I was looking for.

Richard Marlowe replied 4 weeks ago

One more thing, Rob. Can I use lookup to populate data from two different forms.
For example:
Get data from Form 1: Country
Get data from Form 2: City that matches with Country in form 1

Rob LeVineRob LeVine replied 4 weeks ago

I suggest reading this page about dynamic cascading - https://formidableforms.com/knowledgebase/dynamic/#sts=Set%20up%20cascading%20fields

Richard Marlowe replied 3 weeks ago

Thank you for sharing the KB! It worked well when each dropdown pulled data from a different form. However, when I tried having two dropdowns in the same form, where the second is based on the first's selection, it didn’t work.

Rob LeVineRob LeVine replied 3 weeks ago

Please explain what part is not working.

Richard Marlowe replied 3 weeks ago

Hi Rob, below is an outline of how my forms are structured:

Form 1:
•Field: Country (Text)

Form 2:
•Dynamic Dropdown: Loads data from Form 1 (Field: Country)
•Field: City (Text)

Form 3:
•Dynamic Dropdown 1: Loads data from Form 1 (Field: Country)
•Dynamic Dropdown 2: Loads data from Form 2 (Field: City)
•Field: Name (Text)
•Field: Mobile Number (Phone)

Form 4:
•Dynamic Dropdown 1: Loads data from Form 1 (Field: Country)
•Dynamic Dropdown 2: Loads data from Form 2 (Field: City)
•Dynamic Dropdown 3: Loads data from Form 3 (Field: Name)
•Dynamic Dropdown 4: Loads data from Form 3 (Field: Mobile Number)

The Issue:

•Up to Form 3, everything works as expected.
•In Form 4, I can successfully filter "Country," "City," and "Name."
•However, the Mobile Number dropdown (Dynamic4) doesn’t sync with the selected "Name" from Dynamic3. Instead, it shows all mobile numbers from Form 3, irrespective of the selected "Name."

Victor Font answered 1 month ago
I agree with Rob about using Dynamic Lookup fields. What I don't understand is you process. How are users adding multiple cities in Form 2? Are you having them hit submit after every entry? Are you using Ajax to submit the form? Each time you add a city record to Form 2, you are creating a field entry for the dynamic dropdown. This is why you see duplicated county names for each city a user adds. There is a solution, though.
Victor Font replied 1 month ago

The solution means filtering the dropdown values to ensure their uniqueness in the frm_setup_new_fields_vars and frm_setup_edit_fields_vars filter. You can see how the filtering works in the country search dropdown on this page: https://formidable-masterminds.com/developers-directory/

Victor Font replied 1 month ago

I thought I could share the code I use for that dropdown, but it's highly customized for my needs. I created my own SQL to filter the dropdowns. This is a good place for you to start, though: https://formidableforms.com/knowledgebase/frm_setup_new_fields_vars/#kb-filter-dynamic-field

Richard Marlowe replied 4 weeks ago

Hi Victor

I'm open to suggestions. What I'm trying to achieve is:

1. Form1 contains a single field for typing a "Country."

2. Form2 includes two fields:
A "Country" dropdown field dynamically populated from Form1.
A "City" field where users can manually add cities.

3. Form3 includes three fields:
A "Country" dropdown field dynamically populated from Form2.
A "City" dropdown field dynamically populated from Form2.
A "State" field where users can manually type their state.

Richard Marlowe replied 4 weeks ago

I'm trying to figure a way to make the Country field added once then linked to other forms, that way if I modified the Country name it will be applied to all forms that linked to Country field along with City name.

Victor Font replied 4 weeks ago

Follow the directions in the KnowledgeBase article Rob referred you to. It gives you step by step instructions.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right