Support

Account

Home Forums Add-ons Repeater Field Nested Repeater Bootstrap Tabs Reply To: Nested Repeater Bootstrap Tabs

  • yes, you’re using the same field name in both the outer and nested row. See the comment I added to your code

    
    <div>
        <!-- Check for parent repeater row -->
        <?php if( have_rows('menu_sections') ): ?>
            <ul class="nav nav-tabs" role="tablist">
                <?php $row = 1; // number rows ?>
                <?php // Step 1: Loop through rows, first displaying tab titles
                while( have_rows('menu_sections') ): the_row();
                    //  ?>
                    <li role="presentation" class="list-unstyled<?php if($row == 1) {echo 'active';}?>">
                        <a
                                href="#<?php echo $row; ?>"
                                role="tab"
                                data-toggle="tab"
                        >
                            <?php the_sub_field('section_title'); ?>
                        </a>
                    </li>
    
            </ul>
    /***************************************************************
    The field name used in the outer loop should be menu_sections just
    like the above loop. You may also need to reset_rows() here.
    ***************************************************************/
        <?php if( have_rows('section_items') ): ?>
            <div class="tab-content">
                <?php $row = 1; // number rows ?>
                <?php // Step 2: Loop through rows, now displaying tab contents
                while( have_rows('section_items') ): the_row(); ?>
    
                    <?php // Display each item as a list ?>
                    <div class="tab-pane <?php if($row == 1) {echo 'active';}?>" id="<?php echo $row; ?>">
                        <ul>
                            <li class="list-unstyled"><?php the_sub_field('dish_name'); ?></li>
                            <li class="list-unstyled"><?php the_sub_field('dish_description'); ?></li>
                            <li class="list-unstyled"><?php the_sub_field('dish_price'); ?>
                        </ul>
                    </div>
                <?php $row++; endwhile; // (have_rows('section_items') ):?>
            </div>
    
        <?php endif; // (have_rows('section_items') ): ?>
    
            <?php $row++; endwhile; // (have_rows('menu_sections') ):?>
        <?php endif; // (have_rows('menu_sections') ): ?>
    </div>