How to programmatically read the display name of a CCK field from the allowed list? 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:

node-&gt;country


and its value can be found by accessing:

node-&gt;country[0]['value']


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

array(
  'US' =&gt; 'United States',
  'UK' =&gt; '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().