I have 1 field collection
Field collection: CKT Info child2
machine name: field_ckt_info_child2
In that have 2 fields:
Field1: English CKT child2
machine name: field_eng
Field2: Maths CKT Child2
Machine name: field_maths_ckt_child2
I have set field setting "unlimited" to this field collection. Now I just want to add new field collection item in existing Field collection(CKT Info child2) programmatically. I have tried below code but it's not creating new field collection item.
function createFC() {
$field_collection_item = entity_create('field_collection_item', array('field_name' => 'field_maths_ckt_child2'));
$field_collection_item->setHostEntity($node);
$field_collection_item->set('field_maths_ckt_child2', "SET SUCCESS");
$field_collection->save();
}