I need the safe output of a key from a select list field within a field collection item.
I'm theming a field collection item and one of the fields is a select list like:
icon-map|Map
icon-info|Info
icon-pencil|Pencil
I'm using the following to create some easy to use variables;
$fields = array_keys($content);
foreach ($fields as $field) {
$field_items = field_get_items('field_collection_item', $content[$field]['#object'], $field);
$$field = render(field_view_value('field_collection_item', $content[$field]['#object'], $field, $field_items[0]));
}
This works fine for all fields except for the select list. I need the key
of that select list. For this select list field, $field_items
is an array which looks like:
array(1) { [0]=> &array(1) { ["value"]=> string(13) "icon-map" } }
However, $field_icon
(result of $$field = render(..)
) is Map
, which makes sense.
I can get the key by using $field_items[0]['value']
but I'm not sure that's the best way.