1

Is it possible to get weight(order index) of multi field "field collection".This weight is needed inside computed field which is inside field collection.I tried the following but it returns empty

$wrapper = entity_metadata_wrapper('field_collection_item', $entity);    
$instance = field_read_instance('field_collection_item',$wrapper, 'bundle_name');
dpm($instance['widget']['weight']);

Here is the structure

main_content-contains field collection (multi value)
------field collection(s)-contains 1 text field and 1 computed field
------|----item 0
------|-------|-------computed_field <---here how to get weight of field collection item ie 0
------|----item 1
------|-------|-------computed_field <---here how to get weight of field collection item ie 1
------|----item 2
------|-------|-------computed_field
------|----item n
------|-------|-------computed_field

1 Answer 1

3

I was searching in wrong path :( this is found at

http://drupalcontrib.org/api/drupal/contributions!field_collection!field_collection.module/class/FieldCollectionItemEntity/7

code for getting delta is

$wrapper = entity_metadata_wrapper('field_collection_item', $entity);
$cur_delta=$wrapper->delta();
1
  • Thank you for referencing this method. Note that the "delta" method also works after using the function "field_collection_field_get_entity" which allows you to get the entity from the field collection. Cheers.
    – Mario Awad
    Commented May 10, 2014 at 9:32

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