Home › Forums › Add-ons › Flexible Content Field › Populate select fields dynamically using JavaScript API › Reply To: Populate select fields dynamically using JavaScript API
The issue is that the selected value is not available in the choices when the field is loaded and displayed. There needs to be two parts, the JS AJAX part that your using and a PHP part that creates the choices when the field is initially displayed.
This can be accomplished by creating an acf/prepare_field filter. In this filter you can do 1 of 2 things.
I generally opt for #1 because it is faster and easier to do this in php rather than make the extra AJAX request.
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.