I'm trying to save information into an entity build with eck, this entity has a field_collection with more fields.
I have take a look around internet, and I only find examples that works with node entity and user entity, but when I try to use the same code with my entity, it doesn't works.
This is my code:
<?php $idform = 1; $entity = entity_load('formulario',array($idform)); //dpm($entity); $newfield_collection = entity_create('field_collection_item', array('field_name' => 'field_form_field')); $newfield_collection->setHostEntity('formulario',$entity); $newfield_collection->field_name[LANGUAGE_NONE]='name3'; $newfield_collection->field_form_id[LANGUAGE_NONE]['0']['value']=3; $newfield_collection->field_sff_name[LANGUAGE_NONE]['0']['value'] = 'value name 3'; $newfield_collection->field_field_id[LANGUAGE_NONE]['0']['value'] = '13434'; $newfield_collection->field_field_type[LANGUAGE_NONE]['0']['value'] = 'value type 3'; $newfield_collection->save(FALSE); ?>
And this is my error message:
EntityMalformedException: Missing bundle property on entity of type formulario. in entity_extract_ids() (line 7633 of /home/oscar/webapps/www/drupal/drupal7/includes/common.inc).
I have debuging the code and seems that the problem is with
setHostEntity But I don't know if it's because I build the entity with eck module.