diff --git a/entityreference.module b/entityreference.module
index 5f03c5b..16f395b 100644
--- a/entityreference.module
+++ b/entityreference.module
@@ -812,8 +812,10 @@ function entityreference_field_widget_form(&$form, &$form_state, $field, $instan
     $entity_labels = array();
 
     // Build an array of entities ID.
-    foreach ($items as $item) {
-      $entity_ids[] = $item['target_id'];
+    if (!empty($items)) {
+      foreach ($items as $item) {
+        $entity_ids[] = $item['target_id'];
+      }
     }
 
     // Load those entities and loop through them to extract their labels.
