Hello,
I’m dynamically pulling in data via Datatables. In that dynamic data is an acf_form() (with post_id and keys assigned). I’m opening this acf_form() via MagnificPopup. Using their open
method I call:
acf.doAction( 'append', formContent )
The problem I’m running into is that if I console log the acf
object, acf.data.post_id is NULL, acf.data.screen is NULL, and acf.data.validation is off. It seems like calling append() isn’t reinitializing the acf object.
If I inspect the form in the modal window I see that in the id="acf-form-data"
that the provided Post ID is assigned properly but it’s just that the ACF JS object isn’t picking it up.
Is there a way I can reinitialize the JS ACF Object so that it pulls the proper post_id based on a supplied form?
I think one issue might be that there are multiple forms on the same page. What I ended up doing was simply setting the values manually whenever the modal opens:
acf.set( 'post_id', formContent.find( '#_acf_post_id' ) );
acf.set( 'screen', 'acf_form' );
acf.set( 'validate', true );