Support

Account

Home Forums Add-ons Repeater Field Show repeater rows based on radio value Reply To: Show repeater rows based on radio value

  • Hi Elliot,
    I’m trying to do something similar. I tried the code above and it didn’t work for me.
    I’m trying to create a page with Events Listings. But I’d just like to use one repeater field that has about 6 sub-fields. One of those sub-fields is a selection field called “date_category” with a selection of Current Event and nothing else. So the user would then select if the event is current or if they select nothing, it will go into the archived section of the page. In my template, I’ve duplicated the repeater fields in both selections… see my code…I would actually like to place all the Archived Listings inside a Jquery accordion, so that all the archives would be hidden until the user expands them, but the current events would be listed one after the other, as normal. The problem is that my code creates an accordion for each listing, instead of grouping them all together under one accordion. See my code below. Is there a way to group them?

    Thanks for your help.

    <div class="events">
    <?php if(get_field('event_listings')): ?> 
    <?php while(has_sub_field('event_listings')): ?>
    						
    <?php  if(get_sub_field('date_category') == "Current Event") { ?>
    											    	
    <div class="event_listings">
    <div class="date"><strong>Event Date:</strong> <?php the_sub_field('date'); ?></div>	
    <div class="title"><?php the_sub_field('title'); ?></div>
    
    <p><?php the_sub_field('description'); ?></p>
    															
    <div class="meta"><strong>Time:</strong> <?php the_sub_field('time'); ?></div>
    <div class="meta"><strong>Location:</strong> <?php the_sub_field('location'); ?></div>
    <div class="meta"><strong>Attendance:</strong> <?php the_sub_field('attendance'); ?></div>
    <div class="meta"><strong>Type:</strong> <?php the_sub_field('type'); ?></div>
    </div><!--End Event Listings-->
    							
    
    <?php  } else { ?>
    							
    <div class="expand">Archived Listings</div>
    							
    <div class="event_listings collapse">
    <div class="date"><strong>Event Date:</strong> <?php the_sub_field('date'); ?></div>	
    <div class="title"><?php the_sub_field('title'); ?></div>
    																		
    <p><?php the_sub_field('description'); ?></p>
    															
    <div class="meta"><strong>Time:</strong> <?php the_sub_field('time'); ?></div>
    <div class="meta"><strong>Location:</strong> <?php the_sub_field('location'); ?></div>
    <div class="meta"><strong>Attendance:</strong> <?php the_sub_field('attendance'); ?></div>
    <div class="meta"><strong>Type:</strong> <?php the_sub_field('type'); ?></div>
    </div><!--End Event Listings-->
    							
    <?php } ?>
    						
    							
    <div style="margin-bottom:20px;"></div>
    <?php endwhile; ?> 
    <?php else : ?>
    <p>There are no event listings at this time.</p>
    <?php endif; ?>					
    </div>