Filling compound field programatically fails with EntityMetadataWrapperException I followed the instruction in the post from here to create a compound field and it work like a charm. Now I am trying to fill each of the 3 "columns" that make the compound field programmatically and I can figure it out how. 

I am using the entity API to create the node see the code below:

$node = entity_create('node', array('type' =&gt; 'MY-CONTENT-TYPE'));
$entity = entity_metadata_wrapper('node',  $node);

$data = array('column_1'=&gt;'value 1', 'column_2'=&gt;'value 2', 'column_3'=&gt;'value 3');

$entity-&gt;field_custom_compound_field = $data;

$entity-&gt;save();


But it does not work. What am I missing?

Note: I keep getting the error:


  EntityMetadataWrapperException: Unknown data property field_custom_compound_field.
I am posting this here in case someone is having the same issue:

I use the tutorial located here to create my compound custom field with multiple columns what I didn't noticed was in the hook_fields_field_info() implementation I should define the type of data the entity will take. To make things worse in the tutorial the author use the example where all the fields he created are text fields, but in my case I have date, decimal and text fields so I had to define each type. I found the solution in this post.

In a nutshell in my hook_fields_field_info() implementation I have to declare the entity property type, but since I am using multiple columns on the field I have to implement a call back function that will allow me to define the property type for each of my columns.

/**
* Implements hook_field_info().
*
* Provides the description of the field.
*/
function field_example_field_info() {
  return array(
  // We name our field as the associative name of the array.
    'field_example_rgb' =&gt; array(
      'label' =&gt; t('Example Color RGB'),
      'description' =&gt; t('Demonstrates a field composed of an RGB color.'),
      'default_widget' =&gt; 'field_example_3text',
      'default_formatter' =&gt; 'field_example_simple_text',
      'property_type' =&gt; 'field_example_rgb', // we add the propert type here
      'property_callbacks' =&gt; array('field_example_rgb_property_info_callback'), // we add the callback
    ),
  );
}


Call back function to define each columns type:

function field_example_rgb_property_info_callback(&amp;$info, $entity_type, $field, $instance, $field_type) {
  $property = &amp;$info[$entity_type]['bundles'][$instance['bundle']]['properties'][$field['field_name']];

  $property['getter callback'] = 'entity_metadata_field_verbatim_get';
  $property['setter callback'] = 'entity_metadata_field_verbatim_set';
  unset($property['query callback']);

  $property['property info']['rgb'] = array(
    'type' =&gt; 'text',
    'label' =&gt; t('RGB'),
    'setter callback' =&gt; 'entity_property_verbatim_set',
  );
  $property['property info']['someothervalue'] = array(
    'type' =&gt; 'text',
    'label' =&gt; t('Some other value'),
    'setter callback' =&gt; 'entity_property_verbatim_set',
  );
}


After doing that the following code:

$node = entity_create('node', array('type' =&gt; 'MY-CONTENT-TYPE'));
$entity = entity_metadata_wrapper('node',  $node);

$data = array('column_1'=&gt;'value 1', 'column_2'=&gt;'value 2', 'column_3'=&gt;'value 3');

$entity-&gt;field_custom_compound_field = $data;

$entity-&gt;save();


Worked like a charm.