How to write a property callback for a custom field to use with the Entity module I have a custom field with multiple values. I would like it to work with the Entity module. I need to create the correct property_callbacks in hook_field_info(). My field schema looks like this:

'ref' =&gt; array(
  'type' =&gt; 'varchar',
  'length' =&gt; 32, 
  'not null' =&gt; TRUE,
),
'title' =&gt; array(
  'type' =&gt; 'varchar',
  'length' =&gt; 255,
  'not null' =&gt; TRUE,
  'default' =&gt; '',
),
'description' =&gt; array(
  'type' =&gt; 'text',
  'not null' =&gt; TRUE,
  'size' =&gt; 'big',
),
'weight' =&gt; array(
  'type' =&gt; 'int',
  'unsigned' =&gt; TRUE,
  'not null' =&gt; TRUE,
  'default' =&gt; 0,
),
'status' =&gt; array(
  'type' =&gt; 'int',
  'unsigned' =&gt; TRUE,
  'not null' =&gt; TRUE,
  'default' =&gt; 1,
),


Does anyone know how to actually do this? There is very little documentation around for it.
Kind of :) ... if its just numbers and strings you can cheat a little. I added some basic integer columns to the User table and wanted EntityAPI and views etc to be aware of them and did the following:

/**
 * Implementation of hook_entity_property_info(). This dpeends on the EntityAPI.
 *
 * This defines the properties/attributes/"fields" of our Entity regardless of
 * whether they are drupal Fields or custom data (in the base table).
 */
function dew_nagging_entity_property_info_alter(&amp;$info) {
  $properties = &amp;$info['user']['properties'];
  $properties['dew_survey_count_to_complete'] = array(
    'label' =&gt; t('Number of Surveys to Complete'),
    'type' =&gt; 'integer',
    'description' =&gt; 'When a student logs in the system derives how many surveys they must complete. We store this value to make sending the nag email business logic easier.',
    'schema field' =&gt; 'dew_survey_count_to_complete',
    'getter callback' =&gt; 'entity_property_verbatim_get',
    'setter callback' =&gt; 'entity_property_verbatim_set',
  );
  $properties['dew_survey_completed_count'] = array(
    'label' =&gt; t('Number of Completed Surveys to Date'),
    'type' =&gt; 'integer',
    'description' =&gt; 'This is a count of the completed surveys completed by a student in real-time. We store this value to make sending the nag email business logic easier.',
    'schema field' =&gt; 'dew_survey_completed_count',
    'getter callback' =&gt; 'entity_property_verbatim_get',
    'setter callback' =&gt; 'entity_property_verbatim_set',
  );
  $properties['dew_surveys_all_completed'] = array(
    'label' =&gt; t('Has the student completed all their Surveys?'),
    'type' =&gt; 'integer',
    'description' =&gt; 'This is a boolean indictator (0,1) of whether or not a student has completed their surveys. We store this value to make sending the nag email business logic easier.',
    'schema field' =&gt; 'dew_surveys_all_completed',
    'getter callback' =&gt; 'entity_property_verbatim_get',
    'setter callback' =&gt; 'entity_property_verbatim_set',
  );
  return $info;
}


entity_property_verbatim_set and *_get just pull the field from the database if $info['schema field'] is defined.

I also had to make the DB changes in my .install file with db_add_field() for each database column. I also had to notify EntityAPI of my schema changes to the user table via hook_schema_alter(). All these DB schema fields and EntityAPI meta data field defintions must correlate properly.



if its more complicated, you do something like found in Ubercart products, you're just returning the item from the given Node and Field.

See http://api.ubercart.me/api/drupal/ubercart%21uc_order%21uc_order.module/function/uc_order_uc_order_get_properties/7.

EDIT

Apparently the entity_metadata_* functions have been deprecated and you should call entity_property_verbatim_get(), or entity_property_verbatim_set().