Displaying select (dropdown) sub field of a repeater
-
I have created a repeater, and each row of the repeater has 2 fields: a select (dropdown menu) and an Enhanced Message field. The goal is to be able to display the value selected in the dropdown menu in the message field.
Currently, the value that is selected in all rows of the repeater are being displayed. For example: the repeater field display social media options to share the post on (Facebook, Twitter, Instagram, and Reddit). The goal is:
Row 1 – {Facebook is selected} – You have shared on: Facebook
Row 2 – {Twitter is selected} – You have shared on: Twitter
Row 3 – {Instagram is selected} – You have shared on: InstagramHowever, I am seeing:
Row 1 – {Facebook is selected} – You have shared on: Facebook Twitter Instagram
Row 2 – {Twitter is selected} – You have shared on: Facebook Twitter Instagram
Row 3 – {Instagram is selected} – You have shared on: Facebook Twitter InstagramThis is my code:
<?php if( have_rows('create_urldfp') ): while( have_rows('create_urldfp') ) : the_row(); ?> <?php $userchoice=get_sub_field('choose_source'); echo 'You have shared to: '.$userchoice; ?> <?php endwhile; endif; ?>
- The topic ‘Displaying select (dropdown) sub field of a repeater’ is closed to new replies.