Home › Forums › General Issues › Auto populate fields based on selection › Reply To: Auto populate fields based on selection
There aren’t any tutorials or a lot of documentation on doing exactly what you want. I used to have examples of doing this, but that was before the new JS API in ACF. All I can do is point you in the right direction.
This all needs to be done using JavaScript and the ACF JS API.
ACF JS API: https://www.advancedcustomfields.com/resources/javascript-api/
Best source of AJAX information for WP: https://codex.wordpress.org/AJAX_in_Plugins
This is one of my old examples, it will not work. ACF no longer has the acf.ajax
object, so you need to do that yourself. Most of what I do for reading and setting fields can now be done using the ACF JS API.https://github.com/Hube2/acf-dynamic-ajax-select-example/tree/master/dynamic-fields-on-relationship
This is another example that works with ACF now, however, the only change I made to get this working was to do the AJAX request differently, while I left most of the rest the same. All of the getting and setting of fields could have been done using the ACF JS API, I just did not realize this at the time. This could be done much better using the API. https://github.com/Hube2/acf-dynamic-ajax-select-example/tree/master/dynamic-select-example
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.