Please, help, how to dynamically load fields in front end form (or update front-end form)?…
Hi @trasyhoob
Your question is to vague for me to answer correctly.
Can you please elaborate?
Thanks
E
Hello, I have a number of taxonomies, frond end ACF form and html-select of this taxonomies. I want to load group of fields which match selected taxonomy dynamically… (via ajax)… how i can do this…?
Hi @trasyhoob
Just to clarify, are you saying:
You have a front end form for editing a post. When you select a taxonomy value for this post, you would like ACF to load in any new field groups which now match (like in the wp-admin)?
I’m trying to do something similar I think. I need to insert a new post on the frontend. I’m doing something like the following:
acf_form(array(
'post_id'=> 'new',
'field_groups'=>array(123, $AllFieldgroupsAssignedToThisPostType)
);
How can I get the field_groups assigned to the post type?
Hi @wullaski
This is possible by running the ACF location rule match functionality based on the current screen.
something like this should work:
<?php
// get field groups
$filter = array(
'post_type' => 'post',
'post_id' => 0
);
$field_groups = array();
$options['field_groups'] = apply_filters( 'acf/location/match_field_groups', $field_groups, $filter );
?>
Note: this is based of the api.php -> acf_form function and has not been tested
Worked like a charm. Thanks for the help.