Home › Forums › Backend Issues (wp-admin) › ACF Javascript API – Dynamically Update select2 Field Options › Reply To: ACF Javascript API – Dynamically Update select2 Field Options
Actually, no, there’s nothing in the API that I’m aware of that will let you update the options in the select field. You’d still need to do it manually. The only way I’ve found to do this is to destroy all of the existing options and rebuild them every time. You can see an example of this here https://github.com/Hube2/acf-dynamic-ajax-select-example/blob/master/dynamic-select-example/dynamic-select-on-select.js in the “update_cities_on_state_change” function
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.