Home › Forums › Front-end Issues › Pre-fill acf_form fields based on query parameter › Reply To: Pre-fill acf_form fields based on query parameter
Hi @pkarjala
Interesting workflow 🙂
I got some tips for you that you may or may not know about..
A relationship field uses ajax to find posts so you might not be able to just find the post you’re looking for in the already loaded posts if there’s many.
There’s a js event you can use to start up your own js code when the relationship field is shown:
acf.add_action('show_field', function( $field, context ){
// context is a string of either 'tab' or 'conditional_logic'
// do something to $field
});
http://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/
I’m thinking you’d have to run some custom AJAX on this event. Look up the GET parameter (can be done via JS if you like) and run AJAX to find all the information needed to inject the post information into the relationship field.
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.