drupaldrupal-7drupal-viewsdrupal-templates

Drupal select list key in template file


How would I go about getting the key of a select list field in a view template (Row style output)?

The field is added to my view and hidden from display. It contains stuff like:

red|Red
green|Green
blue|Blue

How can I get the selected key (ie. red) for the field in the template?

I was able to print it using:

$view->field['field_color']->view->result[0]->field_field_color[0]['raw']['value']

but I wonder if there is an easier way to get that key.

Thanks in advance.


Solution

  • $row->field_field_color[0]['raw']['value'];