Is there a way to display the code option label in a token, instead of the stored option value (which is the option key in the key => label pair)?
Example:

function mymodule_get_status_codes() {
  return array(
    'open' => 'Still open!',
    'closed' => 'Closed',
  );
}

[node:field_status] token returns 'open'. But I would need to use the 'Still open!' option label, in an e-mail template in my use case.

Comments

Pasqualle’s picture

Codes module does not have any special token support, it should work same as "list (text)" field.

try [node:field-fieldname:value], not sure if it works..
http://drupal.org/node/691078?page=1

Pasqualle’s picture

This is how to switch node tokens to not show code but label:
1. go to you content type display settings (admin/structure/types/manage/page/display for "page" node type)
2. Enable custom view mode "Tokens"
3. go to "Tokens" view mode and on your code field set format to "Default" (or "Div with class")

now your [node:field_status] token will return the code label (in you example as 'Still open!')

Pasqualle’s picture

Title: Support for code option labels in tokens » Code label as token
Component: Code » Documentation
Category: Support request » Task
Issue summary: View changes

This should have a documentation..