Home › Forums › General Issues › Nested repeater and true/false field
I’m trying to create a pricing table with four columns for three products. Instead of an html table, I’m using divs and list elements to make it easier for responsive.
A list of features will be listed in the first column and the three columns to the right will contain a tick if the product contains the feature or will be blank if it doesn’t.
I have created a Repeater field called ‘features’ containing a text field called ‘feature’ and three other repeater fields product_1, product_2 and product_3. Each of the nested repeater fields contain a True/False field called ‘included’
I can get the first column of features to display no problem, but I can’t seem to get the true/false columns to work.
<div class="one-fourth first"> <?php if ( have_rows('features', 11) ): ?> <ul> <?php while ( have_rows('features', 11) ): the_row(); ?> <li><?php the_sub_field('feature'); ?></li> <?php endwhile; ?> </ul> <?php endif; ?> </div> <div class="one-fourth"> <?php if( have_rows('product_1', 11) ): ?> <ul> <?php while ( have_rows('product_1', 11) ): the_row(); ?> <?php if ( 'yes' == the_sub_field('included') ): ?> <li><span class="dashicons dashicons-yes"></span></li> <?php else: ?> <li></li> <?php endif; ?> <?php endwhile; ?> </ul> <?php endif; ?> </div>
Can you provide more information about the field setup? Your description is a little confusing. Maybe you can provide an image that shows the ACF field group or attach an export of the field group.
Hi – thanks for your reply.
I’ve attached a screenshot of how the table looks in the admin area. As it’s a repeater, more rows can be added as required.
See attached screenshot. I’ve also included the field export.
After looking at this I have another question or two.
In the code you originally posted what does
if ( have_rows('features', 11) ):
Using just html, without using any loops, can you code what you’d like it to look like? I’m not sure I understand from the description.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
ACF wouldn’t be so widely used in WordPress if it didn’t have some pretty amazing capabilities. In this article, we look at a few of the features we’ll discuss during “7 things you didn’t know you could do with ACF” at #WPEDecode later this month. https://t.co/5lnsTxp81j pic.twitter.com/Yf0ThPG1QG— Advanced Custom Fields (@wp_acf) March 16, 2023
© 2023 Advanced Custom Fields.