I'm able to retrieve the fields of the field collection attached to my content type, using codes like :
foreach ($entity->field_collection[LANGUAGE_NONE] as $line) {..}
or from an entity wrapper.
But I'm definitely unable to update the collection fields with values computed in the computed field, like I usually do with other CCK fields, like :
$entity->field_regular[LANGUAGE_NONE][0]['value'] = $value ;
then it is saved normally, as if I edited field_regular 'by hand'.
with collection this won't work (does nothing visible) :
$entity->field_collection[LANGUAGE_NONE][$key]['field_coll_field0'][LANGUAGE_NONE][0]['value'] = $value ;
// entity wrapper way
$coll = entity_load('field_collection_item', array($line['entity']->item_id));
$wcoll = entity_metadata_wrapper('field_collection_item', $coll[$key);
$wcoll->field_coll_field0->set($value) ;
any save() methods gives me a blank page (infinite cgi loop) :
entity_save('field_collection_item',$coll);
wcoll->save();
what should I know to programmatically save collection fields ? thanks, Jerome
Please check Entity metadata wrappers doc page with simple example how to update a field collection, for example:
So probably you need to do as below:
Adding
try/catch
should prevent you from having a blank page. However if you've still an issue, check watchdog logs or any errors in PHP log file.