Hello,
Thanks for the feedback! May I know if you’re using the native ACF Form feature or the ACF Extended Form feature?
Thanks in advance.
Regards.
Thanks for the tremendously fast response!
I’m using the acf_form() function to create the front-end form. https://www.advancedcustomfields.com/resources/create-a-front-end-form/
Hello,
I just tested, and it works fine here. The Field group is loaded in PHP only (in the /acfe-php folder).
Please do the following checks:
– Check if the field group correctly appear in the “Local” tab in the ACF UI
– Test the ACF Form using the native way, in a new page:
<?php acf_form_head(); ?>
<?php get_header(); ?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php while(have_posts()): the_post(); ?>
<?php acf_form(array(
'field_groups' => array('group_5eb2fea083b70'),
'submit_value' => __('Update')
)); ?>
<?php endwhile; ?>
</div>
</div>
<?php get_footer(); ?>
Regards.
Ah! I’ve found the issue in my logic!! It was totally my fault.
You’re right things work like a charm. Thanks.
Since I’ve got you, I’m wondering if you can shed any advice. So I’m trying to dynamically create the ACF form with certain field_groups. Rather than using keys, I rather use field group names and retrieve the key for each name.
To retrieve the key of a field group, when they were defined the regular ACF wp-admin way, I used to do this:
$field_group_IDs[] = get_page_by_title( $field_group_name, OBJECT, 'acf-field-group' )->ID;
Which of course doesn’t work when I’ve now switched to registering the field groups locally via php. So the way I’ve found to find them from the local store is as follows:
$field_group = acf_get_local_store( 'groups' )->query( array( 'title' => $field_group_name ) );
$field_group_key = array_key_first($field_group);
Does this seem like the most efficient way of retrieving these?
Thanks!
David
-
This reply was modified 6 years, 1 month ago by
David Bee.
Hello,
Your solution seems fine, but it will only work with local field groups. If you want to check all DB + local field groups, I would suggest you to use acf_get_field_groups() and loop through it to retrieve the field group key based on the said title.
Have a nice day.
Regards.
This was a marvelous idea! Thanks!
David