• Resolved David Bee

    (@davidbawiec)


    First off: THANK YOU for including the JSON and PHP auto sync options in ACF-E!

    I do have an issue, that may be in fact a bug report.

    I’m using the PHP auto sync feature, where my field groups get beautifully saved to the theme’s /acfe-php/ folder. As I deploy the site from my development server to the production server, everything works like a charm. The field group gets auto registered and works great.

    However, I’ve found that I’m unable to use those field groups on ACF front-end forms. It’s as if the field group doesn’t exist. Is it possible that the groups get registered too late? The front-end form gets created within a custom plugin that hooks into a shortcode. It works like a charm if the field groups are loaded from the DB, but not when they’re loaded via the synced PHP files.

    Let me know your thoughts or if I’m missing something.
    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    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.

    Thread Starter David Bee

    (@davidbawiec)

    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/

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    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.

    Thread Starter David Bee

    (@davidbawiec)

    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 4 years, 10 months ago by David Bee.
    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    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.

    Thread Starter David Bee

    (@davidbawiec)

    This was a marvelous idea! Thanks!
    David

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Auto PHP Sync files don’t load on front-end forms’ is closed to new replies.