Hi
I’m slightly confused as to why there is documentation for _everything_ else apart from the radio button field?
I’ve got a radio button which has this in the “Choices” box on backend:
option1 : Option 1 text
option2 : Option 2 text
What I want to do is retrieve the contents of the label – ie if someone selectes option1 then I want “Option 1 text”.
I’d assumed that this would work with the same approach as with checkbox – ie
$field = get_field_object(‘field_name’);
$value = get_field(‘field_name’);
$label = $field[‘choices’][ $value ];
but – I get an error “Undefined index: choices” if I try this….?
thanks
Mike
Hi,
I had the same problem. It was because I changed the value of my radio button after I already saved posts / pages with the old value and the choices no longer matched what was in the database.
I solved it by simply making another choice and updating the post / page. Hope that works for you.
<?php
if(have_rows(‘wine_list’)):
while(have_rows(‘wine_list’)): the_row();
if(get_sub_field(‘display’) == ‘yes’){?>
<section class=”block2″><?php the_sub_field(‘wine_list__content_1’); ?></section>
<?php }
endwhile;
endif;
?>