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")?

2 Answers 2


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().


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.

  • It's not available. I thought there was an API for that?
    – haggag
    Jun 13, 2012 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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