Skip to main content

Posts

Showing posts from February, 2014

Drupal 7 Field collection on new node creation

Use $node = new StdClass(); to create the node through program. Or Example for creating node through program After node_save($node), You will get the 'nid' of created node $nid = $node->nid; Then again you load the created node from above nid $node_loaded = node_load($node->nid); then create the field collection as, $node = new StdClass();  $node ->-----// node values.....  node_save($node);  nid = $node-nid;// after saving the new it will return the nid in $node->nid in Drupal 7  node_loaded = node_load($nid);  $field_collection_item = entity_create('field_collection_item',array('field_name' => 'field_event_conference')); // fied_name  in the node manage fields $field_collection_item->setHostEntity('node', $node_loaded); $field_collection_item->field_fc_company[LANGUAGE_NONE]['0']['value'] = $company; $field_collection_item->save(); Field collection contains another f