Home › Forums › Add-ons › Repeater Field › Getting Values and Labels Of A Sub Field
Hi,
I am using a Radio Button inside a Repeater Field,
to create two selects filters in this page [ demo filter ]
As you can see opening one of the select, I am getting the same option repeated x times.
What I’d like to get is only one instance of the option regardless how many squares have that class in the page.
I was wondering if there is a simple and clean solution for this issue.
Below the code responsible to output the selects and their option fields
<div class="block-filter block-filter--area btn-skin u-cf"><!-- Area -->
<label class="block-filter__label u-textCapitalize u-block u-textLeft" for="area">area</label>
<span class="block-filter__select-wrapper" id="area">
<select id="select--areas">
<option value="all--areas">All</option>
<?php if( get_field('neighbourhood') ): ?>
<?php while( has_sub_field('neighbourhood') ):
$area = get_sub_field_object('neighbourhood_area');
$area_value = get_sub_field('neighbourhood_area');
$area_label = $area['choices'][$area_value];
?>
<option value="<?php echo $area_value; ?>"><?php echo $area_label; ?></option>
<?php endwhile; ?>
<?php endif; ?>
</select>
</span>
</div>
<div class="block-filter block-filter--type btn-skin u-cf"><!-- Type -->
<label class="block-filter__label u-textCapitalize u-block u-textLeft" for="type">type</label>
<span class="block-filter__select-wrapper" id="type">
<select id="select--types">
<option value="all--types">All</option>
<?php if( get_field('neighbourhood') ): ?>
<?php while( has_sub_field('neighbourhood') ):
$type = get_sub_field_object('neighbourhood_type');
$type_value = get_sub_field('neighbourhood_type');
$type_label = $type['choices'][$type_value];
?>
<option value="<?php echo $type_value; ?>"><?php echo $type_label; ?></option>
<?php endwhile; ?>
<?php endif; ?>
</select>
</span>
</div>
The topic ‘Getting Values and Labels Of A Sub Field’ is closed to new replies.
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.