You know the forms that exist on the Web where someone selects a “Country”, and then suddenly the “State/Province” field filters appropriately (originally starting as empty)?
I want to achieve that with ACF. I have read throughout the Forums people asking for the same thing but it doesn’t seem to ever get resolved.
I understand how to pre-populate a select field in general… I do it all the time. For example… I have an Options Page, where the Admin enters a series of “choices” and then I grab those “choices” on-the-fly to pre-populate a Select Field. That’s not what I am asking for here.
I have a CPT for “Products”…
And, I have a CPT for “Race Tracks”. Each “Race Track” has 1 or more “Products” associated with it.
Finally, I have a CPT for “Orders”.
When creating a new Order, there is a Repeater Field that has 2 Select fields (Post Objects): Race Track, and Product.
I want all the Race Tracks to show up in the list (and they do). Now… I initially want the “Products” to be empty. Only upon selecting a “Race Track” do I want “Products” to populate (with, of course only the “Products” associated with the selected “Race Track”).
I want to do this *without* having to Save the post multiple times. I need AJAX for this… Or… is there a plugin in the wild with a “Filtered Post Object” field type perhaps that I could set conditions on? That’d be cool!
I will keep looking, but just wanted to put this out in the mean time. I will post back if I find a solution. There has to be a straightforward solution to this very common problem.
Thanks for your time,
There’s an old tutorial for this kind of situation. You can check it out here: https://www.bobz.co/dynamically-populate-select-fields-choice-in-advanced-custom-fields/. Because it’s an old tutorial, you need to modify it to fit your needs and the current state of ACF.
I hope this helps 🙂
I’ve spent many many hours with that link, trying to convert it to something that’ll work for my situation, with no luck.
Things are *significantly* different when using Post Objects over a standard Select (a Select is what is being used on bobz.co).
There HAS to be a simple to follow process, or something existing… this is such a common issue with ACF.
Someone else… help???
I am looking to do something similar to what you are trying to accomplish. I ended up stumbling upon this link to an example from a post in the forums. I hope this help.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!