Quantcast
Channel: Tagged with repeater - Plugin Support
Viewing all articles
Browse latest Browse all 160

Was able to get select labels, suddenly now it doesn't work.

$
0
0

Hello,

I'm working on a site where the client can enter addresses, then I sort the addresses by state name (label), and the state abbreviation (value) is included in the addresses. The select is nested in a repeater field.

I had found previous discussions on how to accomplish getting the label, and I was able to have it working for a while. Now it has stopped working but I haven't edited the code that was working or changed any field names. I am still able to echo the select field values. Below is the code:

` <?php while( has_sub_field('retailers_north_american') ): ?>

<?php $parentField = get_field_object('retailers_north_american'); $stateSelect = $parentField['sub_fields']['field_69']; $value = get_sub_field('retailer_northamerican_state'); $label = $stateSelect['choices'][$value]; ?>
                      <h4><?php echo $label ?></h4> 
                      <address>etc</address>
                </li>

<?php endwhile; ?> `

As I said echoing $label is giving me trouble, but I can echo $value without issues. I checked that the select is still field_69 and it is.

Just for kicks I tried print_r($parentField) which returns the whole parent array, so that works. Then I tried print_r($stateSelect) but that doesn't return anything. I'm not sure if it even would, but maybe that will make sense to somebody.

Any help would be greatly appreciated because I'm stumped! Mary

EDIT The label in question that I was trying to echo is, in the case of the option for Alabama: [AL] => Alabama "Alabama" is the label and "AL" is the value.


Viewing all articles
Browse latest Browse all 160

Trending Articles