Last updated 21 July 2014. Created on 21 July 2014.
Edited by apmsooner. Log in to edit this page.
I couldn't figure out how to get the actual label to print instead of the key value. Here is what did the trick for me....
Here's a sample assuming field name is: field_marital_status
The list available values are:
1|Married
2|Single
$status = $entity->field_marital_status[LANGUAGE_NONE][0]['value'];
$status_display = field_view_value($entity_type, $entity, 'field_marital_status', $status, array());
$entity_field[0]['value'] = 'You are' . render($status_display);
Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.
Comments
for dispaly key a field
for dispaly key a field
print render($node->field_list['und'][0]['value']);
also can in manage display change default to key for field
for show image and value of a list or check box use:
field_list is name of my listbox field
field_image is name of my image field
Log in or register to post comments
Use field_info_field()
Try using this :
$key = 0; // Or whatever
$field = field_info_field('field_marital_status');
$label = $field['settings']['allowed_values'][$key];
Log in or register to post comments
Works like a charm
Thank you. It works like a charm.
Log in or register to post comments
来自 https://www.drupal.org/node/2307109