I'm struggling to determine which entity_metadata_wrapper methods are available for a given field. For instance:

  $fields = entity_metadata_wrapper('node', $nid);
  $body = $fields->body->value->value();
  $title = $fields->title->value();
  $type = $fields->type->value();

$body has a different method, where you have to do a ->value->value() for it to work right.

In my situation I'm trying to get the type of the node in Human readable form: "Custom Type" vs. "custom_type". I'm wondering if there is some kind of value() method that returns the human readable version. print_r($fields) avails me not.

Edit: To get the Human readable node type I ended up just using node_type_load. It seems like there should be a more efficient way of doing this using the Entity API, but I can't figure it out.

2 Answers 2


i think the wrapper doesnt provide the type label, at least i havent found it. One way to find the label :

$info = entity_get_info($fields->type());
echo $info['label'];

To learn more about available fields, try $fields->getPropertyInfo().

The diference of the body field is in the fact it is formatted, so the "first" value() function returns the object which allows you to retreive other metadata about the field. The difference can be spotted in the result of the aforementioned getPropertyInfo. While a "plain text" field is set to a callback function "entity_metadata_field_property_get", which returns the value immiediately, the body will have something like "entity_metadata_field_verbatim_get" which returns the whole array of the field.

according to the docs, you can also use value() on the wrapper itself and that will allow you to see what there is (so print_r($fields->value()); or dpm() the same will help :)

  • This was helpful, thanks! I'm still not able to easily discern which entity functions are available... for instance, to get the value of the body field I have to use ->value->value() instead of just ->value()... Commented Apr 20, 2012 at 16:53
  • sorry it took me a while to improve my answer with an explanation on the body problem
    – mojzis
    Commented May 1, 2012 at 18:54

It is possible to query a wrapper for all available fields:

  • Welcome to Drupal Answers! What reported in this answer has already been said in the accepted answer. If you agree with the given answer, when your reputation reaches 15 points, you will be able to up-vote it.
    – apaderno
    Commented Nov 7, 2013 at 7:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.