I have a profile2 profile type. In profile type i have created the collection for storing the information of form fields.
I have used the phone module to create the phone number fields. This collection contains the two phone number fields, one for office and one for mobile.
So my scenario is give below
--Profile type --- Field collection to store the phone numbers ---- Two fields to store phone numbers 1. field_office_phone 2. field_office_mobile
Now i want to save the data of the field programmatically. I have used below snippet from here to create and save the field collection programmatically. In the given below code company is my profile2 profile bundle.
module_load_include('inc', 'field_collection', 'field_collection.pages'); // Load the profile we're adding the field to $profile_entity = profile2_load_by_user($account, 'company'); // Define the values of the new field $values = array(); $values['field_name'] = 'field_contact_number'; // field collection name $values['field_office_phone'][LANGUAGE_NONE]['#value']['number'] = 1234; $values['field_office_mobile'][LANGUAGE_NONE]['#value']['number'] = 12374; // Create the field collection entry and associate it with the profile $field_entity = entity_create('field_collection_item', $values); $field_entity->setHostEntity('profile2', $profile_entity); $field_entity->save();
The above code snippet only creates field but it is not storign the values in the field. I am not getting the reason why it is not setting the values.