Entity_metadata_wrapper and Null Values

Public

Get raw version
php
  1. $wrapper = entity_metadata_wrapper('node', 123);
  2. if($wrapper->__isset('field_middle_name')) {
  3. // Do something awesome with the middle name.
  4. } else {
  5. // Don't do anything awesome, they don't have a middle name.
  6. }

Entity reference fields and field collections

Get raw version
php
  1. // also check if there is an identifier, __isset alone is not enough!
  2. if ($wrapper->__isset('field_project_number') && $wrapper->field_project_number->getIdentifier()) {
  3. $number = $wrapper->field_project_number->field_project_number_complete->value();
  4. return $number;
  5. }