Posted by oskar_calvo on December 19, 2012 at 3:40pm
I have build a entity called "formulario" as machine name, with 3 fields, one of them is a field collection.
I'm trying to add programmatically more content to the field_collection, but I get an error
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).
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][0]='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);
?>Thanks
Oskar