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

    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.