Hi there --
So I'm pulling back a list of nodes and their fields. One of them is a text field that uses a single-select as its widget. Although I know that the key is what's stored in the database, given the widget I'd expect Views to return that key's label when showing me the content of that field for a given node. Instead, I get the key. Is there a best practice, either in the GUI, in template files, or in a module, for translating this into the select field's labels?

Thanks for this awesome module!
Ben

Comments

damiankloip’s picture

Status: Active » Postponed (maintainer needs more info)

What are you trying to do with this data? When a form is posted, the key is what you would get as a value - That's pretty standard I would say. You would need to either store some of your data on the form so you can lookup again based on the id, or just load the entity again?

esmerel’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
manjirik’s picture

Assigned: Unassigned » manjirik
Status: Closed (cannot reproduce) » Active

You can try this.

$key = 0; // Or whatever
$field = field_info_field('field_priority');
$label = $field['settings']['allowed_values'][$key];

manjirik’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)