I am using Drupal 7.x and have a created a custom entity. I am using the Entity API module to extend EntityDefaultMetadataController and override public function entityPropertyInfo() to add properties for displaying when my entity is viewed.
More information on hook_property_entity_info:
I understand how to return different types of properties such as 'text', 'int', 'list', 'entity', and so on, using callbacks. However, I have not been able to successfully return a type of 'struct'. My field is always empty when I try to display it.
Example code:
$info['properties']['my-structure_property'] = array(
'label' => t('My Structure Property'),
'type' => 'struct',
'getter callback' => ? // What should this return?
'property info' => array(
'sub_field1' => array(
'type' => 'text',
'label' => t('Subfield 1'),
'getter callback' => 'entity_metadata_sub_field1_property_get', // Returns a text field
),
'sub_field2' => array(
'type' => 'entity',
'label' => t('Subfield 1'),
'getter callback' => 'entity_metadata_sub_field2_property_get', // Returns an entity
),
),
);
What should I be returning in my callback? I have tried returning an object, an array...?