Support

Account

Home Forums Add-ons Repeater Field Getting Values and Labels Of A Sub Field

Solving

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>
    
  • I have the same problem, please support us

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Getting Values and Labels Of A Sub Field’ is closed to new replies.