Why am I getting the error "Unknown data property" when the field exists? I am trying to grab all of the fields of a node (which I am doing by using array_keys). At this point, I want to feed them all to entity_metadata_wrapper(), and grab their values.

I will then, if they are strings, print them to a PDF document using TCPDF's Text() function.

Everything looks like it will work correctly; however, certain fields give an error as such:


  EntityMetadataWrapperException: Unknown data property field_grade. in
  EntityStructureWrapper->getPropertyInfo()


The field exists in my node, though.

'field_grade' =&gt; 
    array (size=13)
      'default_value' =&gt; null
      'description' =&gt; string '' (length=0)
      'display' =&gt; 
        array (size=4)


This is the code I am using.

$wrapper = entity_metadata_wrapper('node', $node);
$trip_fields = field_info_instances('node', 'trip');
$trip_fieldskeys = array_keys($trip_fields);
$margintop = 0;

foreach($trip_fieldskeys as $item) {
  $value = $wrapper-&gt;$item-&gt;value();
  if (gettype($value) == "string") {
    $pdf-&gt;Text(0, $margintop, $value, false, false, true, 0, 0,
       '', false, '', 0, false, 'T', 'M', false);
    $margintop = $margintop + 25;
  }
}
If it is a custom field that you have defined in your module (using hook_field_info()) then you need to add a property_type to your field info.  See https://www.drupal.org/docs/7/api/entity-api/property-info-for-fields for an example and https://www.drupal.org/node/905580 for a full list of possible types.

If your field is a complex (multiple value) data structure you may also additionally need to include property_callbacks as well.  See http://d7.thecarneyeffect.co.uk/describe-field-properties-make-custom-fields-work-entity-metadata-wrappers for a good example of this.