Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For example if a CCK text field is configured to have the following allowed values:

US|United States
UK|United Kingdom

The node has the corresponding field:


and its value can be found by accessing:


which will return 'US' or 'UK'. What is best way to return the display name which was specified in the allowed list (i.e "United States" or "United Kingdom")?

share|improve this question

You can use the following code.

$field = content_fields($field_name);
$function = $field['module'] . '_allowed_values';
$values = array_values(function_exists($function) ? $function($field) : (array) content_allowed_values($field));

This code is similar to the code used by optionwidgets_options(); the difference is that optionwidgets_options() returns also the value for the empty choice.

The output of content_allowed_values($field) is an array that in your case is the following one.

  'US' => 'United States',
  'UK' => 'United Kingdom',

As you are only interested to the options visible in the user interface, I passed the result of content_allowed_values($field) to array_values().

share|improve this answer

Install the devel module and go to a node with this field and click the devel tab. If its available directly it will show in devel. If not you may have to do a custom db query.

share|improve this answer
It's not available. I thought there was an API for that? – haggag Jun 13 '12 at 16:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.