I currently have the following below as a taxonomy reference field in one of my content types as a checkbox list widget during content creation.

Currently its only showing the term name, but I want it to show the term name and its fields. My end results would be something like this:

nc - North Carolina

nj - New Jersey

ny - New York

How can that be done?

enter image description here

1 Answer 1


I don't think there's a way to do this using the UI, but you should be able to do this using template_preprocess_field().

Store the full version of each acronym as the description on each of your taxonomy terms. The acronym would be the title.

Then you'll want to do something like:

*note that this is all pseudo-code as I don't have a version of Drupal handy to test this, but with some kpr() or var_dump() calls you should be able to debug it for your needs*

function my_theme_preprocess_field(&$vars) {
  $element = $vars['element'];
  // Modify the output of the taxonomy term field
  if ($element['#field_name'] === 'field_my_taxonomy_term') {
    // Get the title and description
    $item = $vars['items'];
    $acronym = $vars['items'][0]['title'];
    $description = $vars['items'][0]['description'];

    //create the html you want
    $html = '<span>'.$acronym.' - '.$description.'</span>';

    //now replace the default field markup with your new markup
    $vars['items'][0]['#markup'] = $html;


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.