0

I have created a content type and take field collection for some field. Within field collection I have taken 4 select box. Now I need to get these select box value in content type tpl file. For this I am using this code : $wrapper = entity_metadata_wrapper('node', $node_data);

but its not giving me select box option value.

3

2 Answers 2

2

Use entity_load('field_collection_item', array($item_id)) or field_collection_field_get_entity($item)

Sample

$node = node_load($id);
$items = field_get_items('node', $node, 'field_fc');
foreach ($items as $item) {
$fc_value = field_collection_field_get_entity($item);
// Do something.
}

For reference link 1, link 2

1

Simple render the field on the node.tpl.php with field machine name:

print render($content['field_collection']);

It's work for me.

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