Populate Dropdown Options based on URL Parameter

By: Mark Hansen | Asked: 10/04/2023
ForumsCategory: General questionsPopulate Dropdown Options based on URL Parameter
Mark HansenMark Hansen asked 1 year ago
I feel like I'm missing something super-simple here, and have used lookup and dynamic fields for a while. I'm just drawing a blank on how to limit my dropdown values to a filtered list of sorts.
  • On Page 1, I have a simple 2-field form with a dropdown (lookup field, pulling options from an existing form) The user submits this form and is lead to a second page, based on their choice. The form action reads their choice and uses a separate lookup field to populate the url they are forwarded to. For the sake of example, assume they chose "Trucks". (I pass "trucks" to page 2, /trucks/ as an url parameter)
  • On Page 2, the page-content is based on their previous selection ie: trucks, and within it I have a second form where they can make a choice of which brand truck they want to see more information about from a dropdown field.
How do I populate and limit the options of that dropdown field to existing form data with the parent entry of trucks? (From a separate form with hundreds of entries, 20 of them listed as trucks)
Adam Fominaya replied 1 year ago

I'm not totally sure I follow, but I just want to make sure that your second lookup field is referencing the first? It needs to be watching the first lookup field

Mark HansenMark Hansen replied 1 year ago

Thanks, Adam. My goal is not to store the entries from the first form, since it's really just being used as a jump-menu, allowing the user to select which type of vehicle, then forwarding them to the correct page and passing the url parameter of the vehicle type.

My issue may lie in the fact that I use a single form populated with the data options for both form 1 and form 2, and hoping filtering could be done at the url paramter level.

IE: User selects trucks from form 1, gets sent to the /trucks/ page, with an url paramter of /?vehicletype=trucks

Next, I was hoping to filter a dropmenu, to show all records in my master data table (same data as form 1, but now filtered to trucks only) and populate the dropdown with the truck brand, ie: Ford, Chevrolet, etc.

paulus macaulus replied 1 day ago

Did you ever get this working? I believe I have the same need.
.
I have "Form A" with postcodes and region data for those postcodes and "Form B" with a Unique list of those Regions and a number that will be used to show product availability for this Region.

The user enters a postcode in "Form C" and pulls the corresponding Region back. This is straightforward enough.
I want to use that returned Region to pull the corresponding value back from "Form B" as available "slots", showing the product's availability for that Region. Upon a successful sale from "Form C", I need to deduct "one" from this slot entry in "Form B" so I don't oversell.
It doesn't work to have the slot number in "Form A" when there are multiple references to the Regions associated with the postcodes, so "Form B" has a unique list of these Regions with a corresponding entry that I want to update holding a number for the product availability of that Region.
I hope you had any luck solving your problem, which sounds similar to what I need to achieve.
I know I'm kind of piggybacking on this post, but given that the use case is so close and you may have found a solution, I thought I would start here first.

1 Answers
Victor Font answered 19 hours ago
Use the rm_setup_new_fields_vars and the frm_setup_edit_fields_vars hooks to populate and filter your dropdowns.

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