Support

Account

Home Forums Add-ons Repeater Field while have_rows not working with acf_add_local_field_group defined field. Reply To: while have_rows not working with acf_add_local_field_group defined field.

  • I’m using the JSON actually to cache my groups. But I thought everytime you make changes locally and push up you have to manually go into the backend and click to refresh the group (circle arrow icon)?

    GROUP (truncated example):

    
    if( function_exists('acf_add_local_field_group') ):
    
    acf_add_local_field_group(array(
        'key' => 'group_597a31e9a49bd2',
        'title' => 'Settings (New)',
        'fields' => array(
            array(
                'key' => 'field_597a32a719ca9',
                'label' => 'Co-Chairs',
                'name' => 'co-chairs',
                'type' => 'repeater',
                'instructions' => '',
                'required' => 0,
                'conditional_logic' => 0,
                'wrapper' => array(
                    'width' => '',
                    'class' => '',
                    'id' => '',
                ),
                'collapsed' => 'field_597a32da19caa',
                'min' => 0,
                'max' => 0,
                'layout' => 'table',
                'button_label' => 'Add Co-Chair',
                'sub_fields' => array(
                    array(
                        'key' => 'field_597a32da19caa',
                        'label' => 'Name',
                        'name' => 'name',
                        'type' => 'text',
                        'instructions' => '',
                        'required' => 0,
                        'conditional_logic' => 0,
                        'wrapper' => array(
                            'width' => '',
                            'class' => '',
                            'id' => '',
                        ),
                        'default_value' => '',
                        'placeholder' => '',
                        'prepend' => '',
                        'append' => '',
                        'maxlength' => '',
                    ),
                    array(
                        'key' => 'field_597a32e719cab',
                        'label' => 'Affiliate',
                        'name' => 'affiliate',
                        'type' => 'text',
                        'instructions' => '',
                        'required' => 0,
                        'conditional_logic' => 0,
                        'wrapper' => array(
                            'width' => '',
                            'class' => '',
                            'id' => '',
                        ),
                        'default_value' => '',
                        'placeholder' => '',
                        'prepend' => '',
                        'append' => '',
                        'maxlength' => '',
                    ),
                    array(
                        'key' => 'field_597a32fe19cac',
                        'label' => 'E-Mail',
                        'name' => 'e-mail',
                        'type' => 'email',
                        'instructions' => '',
                        'required' => 0,
                        'conditional_logic' => 0,
                        'wrapper' => array(
                            'width' => '',
                            'class' => '',
                            'id' => '',
                        ),
                        'default_value' => '',
                        'placeholder' => '',
                        'prepend' => '',
                        'append' => '',
                    ),
                ),
            ),
            
        ),
        'location' => array(
            array(
                array(
                    'param' => 'page_template',
                    'operator' => '==',
                    'value' => 'page-committee-info.php',
                ),
            ),
        ),
        'menu_order' => 0,
        'position' => 'normal',
        'style' => 'default',
        'label_placement' => 'top',
        'instruction_placement' => 'label',
        'hide_on_screen' => '',
        'active' => 1,
        'description' => '',
    ));
    
    endif;

    TEMPLATE:

        <? if ( get_field( 'co-chairs', $settings_page) ) : ?>
        <li>
    
            <? var_dump( $settings_page ); ?>
    
            <h2 class="subheader-small">Co Chairs</h2>
            <ul class="co-chairs">
                <?php while( have_rows('co-chairs', $settings_page) ): the_row(); ?>
    
                <li>
                    <div class="name"><?=get_sub_field('name'); ?></div>
                    <div class="Preheader affiliate"><?=get_sub_field('affiliate'); ?></div>
                    <div class="Preheader email"><a href="mailto:<?=get_sub_field('e-mail'); ?>"><?=the_sub_field('e-mail'); ?></a></div>                           
                </li>
                <? endwhile; ?>
            </ul>
        </li>
        <? endif; ?>