Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

Can someone tell me how can I retrieve values of a taxonomy field inside a field collection of a profile2 node?

Thanks

share|improve this question

1 Answer

up vote 0 down vote accepted

You could try using entity_metadata_wrapper to load the profile2 entity.

You could then drill down to the field value on the field_collection.

Something like:

$profile = profile2_load_by_user($account, 'main');
// Use entity metadata wrapper, because it's awesome.
$profile_wrapper = entity_metadata_wrapper('profile2', $profile);
// We can access the term as the "value" of the field_collection child field
$term = $profile_wrapper->get('field_my_field_collection')->field_my_taxonomy_term->value();
// Just print out the term for now
drupal_set_message('<pre>'.var_export($term,1).'</pre>');
share|improve this answer
Thanks ... this is what I needed with a slight modifications according to my specific requirements. – developer Jan 6 at 14:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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