diff --git a/reference_value_pair.module b/reference_value_pair.module
index 9ca41c2..8b0e082 100644
--- a/reference_value_pair.module
+++ b/reference_value_pair.module
@@ -60,7 +60,7 @@ function reference_value_pair_theme() {
  */
 function template_preprocess_reference_value_pair_formatter(&$variables) {
   $variables['value'] = $variables['item']->value;
-  $variables['label'] = $variables['entity']->label();
+  $variables['label'] = $variables['entity'] ? $variables['entity']->label() : $variables['label'];
 }
 
 /**
diff --git a/src/Plugin/Field/FieldFormatter/ReferenceValueFormatter.php b/src/Plugin/Field/FieldFormatter/ReferenceValueFormatter.php
index 8923720..16b36fa 100755
--- a/src/Plugin/Field/FieldFormatter/ReferenceValueFormatter.php
+++ b/src/Plugin/Field/FieldFormatter/ReferenceValueFormatter.php
@@ -3,7 +3,6 @@
 namespace Drupal\reference_value_pair\Plugin\Field\FieldFormatter;
 
 use Drupal\Core\Field\FieldItemListInterface;
-use Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase;
 use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
 
 /**
@@ -17,7 +16,7 @@ use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
  *   }
  * )
  */
-class ReferenceValueFormatter extends EntityReferenceFormatterBase {
+class ReferenceValueFormatter extends ReferenceValueFormatterBase {
 
   /**
    * {@inheritdoc}
@@ -30,7 +29,7 @@ class ReferenceValueFormatter extends EntityReferenceFormatterBase {
         '#theme' => 'reference_value_pair__formatter',
         '#item' => array(
           'value' => $items[$delta]->value,
-          'label' => $entity->label(),
+          'label' => $entity ? $entity->label() : $items[$delta]->_label,
         ),
       );
 
@@ -39,10 +38,12 @@ class ReferenceValueFormatter extends EntityReferenceFormatterBase {
         '#template' => '{{ label }} {{ value }}',
         '#context' => [
           'value' => $items[$delta]->value,
-          'label' => $entity->label(),
+          'label' => $entity ? $entity->label() : $items[$delta]->_label,
         ],
       ];
-      $elements[$delta]['#cache']['tags'] = $entity->getCacheTags();
+      if ($entity) {
+        $elements[$delta]['#cache']['tags'] = $entity->getCacheTags();
+      }
     }
 
     return $elements;
diff --git a/src/Plugin/Field/FieldFormatter/ReferenceValueFormatterBase.php b/src/Plugin/Field/FieldFormatter/ReferenceValueFormatterBase.php
index e69de29..fb785cc 100644
--- a/src/Plugin/Field/FieldFormatter/ReferenceValueFormatterBase.php
+++ b/src/Plugin/Field/FieldFormatter/ReferenceValueFormatterBase.php
@@ -0,0 +1,161 @@
+<?php
+
+namespace Drupal\reference_value_pair\Plugin\Field\FieldFormatter;
+
+use Drupal\Core\Cache\CacheableMetadata;
+use Drupal\Core\Field\EntityReferenceFieldItemListInterface;
+use Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase;
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\TypedData\TranslatableInterface;
+
+/**
+ * Parent plugin for reference value pair formatters.
+ */
+abstract class ReferenceValueFormatterBase extends EntityReferenceFormatterBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function defaultSettings() {
+    return array(
+      'display_invalid_reference' => TRUE,
+      'invalid_reference_label' => '',
+    ) + parent::defaultSettings();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function settingsForm(array $form, FormStateInterface $form_state) {
+    $elements = parent::settingsForm($form, $form_state);
+
+    $elements['display_invalid_reference'] = array(
+      '#type' => 'checkbox',
+      '#title' => $this->t('Display invalid reference'),
+      '#default_value' => $this->getSetting('display_invalid_reference'),
+      '#min' => 1,
+      '#description' => $this->t('Display the value even if the referenced entity is invalid (e.g. has been deleted).'),
+    );
+    $elements['invalid_reference_label'] = array(
+      '#type' => 'textfield',
+      '#title' => $this->t('Invalid reference label'),
+      '#default_value' => $this->getSetting('invalid_reference_label'),
+      '#description' => $this->t('Label to display when the reference is invalid. Leave empty to not display only the value without a label.'),
+      '#states' => array(
+        'visible' => array(
+          ':input[name*="display_invalid_reference"]' => array('checked' => TRUE),
+        ),
+      ),
+    );
+
+    return $elements;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function settingsSummary() {
+    $summary = parent::settingsSummary();
+
+    $settings = $this->getSettings();
+
+    if (!empty($settings['display_invalid_reference'])) {
+      if (empty($settings['invalid_reference_label'])) {
+        $summary[] = $this->t('For invalid references display the value without label');
+      }
+      else {
+        $summary[] = $this->t('For invalid references use this label: <em>@label</em>',
+          ['@label' => $settings['invalid_reference_label']]);
+      }
+    }
+    else {
+      $summary[] = $this->t('Show only pairs where reference is valid');
+    }
+
+    return $summary;
+  }
+
+
+
+  /**
+   * Returns the referenced entities for display.
+   * @TODO update documentation
+   *
+   * The method takes care of:
+   * - checking entity access,
+   * - placing the entities in the language expected for display.
+   * It is thus strongly recommended that formatters use it in their
+   * implementation of viewElements($items) rather than dealing with $items
+   * directly.
+   *
+   * For each entity, the EntityReferenceItem by which the entity is referenced
+   * is available in $entity->_referringItem. This is useful for field types
+   * that store additional values next to the reference itself.
+   *
+   * @param \Drupal\Core\Field\EntityReferenceFieldItemListInterface $items
+   *   The item list.
+   * @param string $langcode
+   *   The language code of the referenced entities to display.
+   *
+   * @return \Drupal\Core\Entity\EntityInterface[]
+   *   The array of referenced entities to display, keyed by delta.
+   *
+   * @see ::prepareView()
+   */
+  protected function getEntitiesToView(EntityReferenceFieldItemListInterface $items, $langcode) {
+    $entities = array();
+
+    foreach ($items as $delta => $item) {
+      // Ignore items where no entity could be loaded in prepareView().
+      if (!empty($item->_loaded)) {
+        $entity = $item->entity;
+        if ($entity === NULL) {
+          $entities[$delta] = NULL;
+          continue;
+        }
+        // Set the entity in the correct language for display.
+        if ($entity instanceof TranslatableInterface) {
+          $entity = \Drupal::entityManager()->getTranslationFromContext($entity, $langcode);
+        }
+
+        $access = $this->checkAccess($entity);
+        // Add the access result's cacheability, ::view() needs it.
+        $item->_accessCacheability = CacheableMetadata::createFromObject($access);
+        if ($access->isAllowed()) {
+          // Add the referring item, in case the formatter needs it.
+          $entity->_referringItem = $items[$delta];
+          $entities[$delta] = $entity;
+        }
+      }
+    }
+
+    return $entities;
+  }
+
+  /**
+   * {@inheritdoc}
+   *
+   * Loads the entities referenced in that field across all the entities being
+   * viewed.
+   */
+  public function prepareView(array $entities_items) {
+    parent::prepareView($entities_items);
+    $settings = $this->getSettings();
+
+    if (empty($settings['display_invalid_reference'])) {
+      return;
+    }
+
+    foreach ($entities_items as $items) {
+      foreach ($items as $item) {
+        if ($item->_loaded) {
+          continue;
+        }
+        $item->_loaded = TRUE;
+        $item->entity = NULL;
+        $item->_label = $settings['invalid_reference_label'];
+      }
+    }
+  }
+
+}
diff --git a/src/Plugin/Field/FieldFormatter/ReferenceValueTemplateFormatter.php b/src/Plugin/Field/FieldFormatter/ReferenceValueTemplateFormatter.php
index 40743db..da224a4 100755
--- a/src/Plugin/Field/FieldFormatter/ReferenceValueTemplateFormatter.php
+++ b/src/Plugin/Field/FieldFormatter/ReferenceValueTemplateFormatter.php
@@ -3,7 +3,6 @@
 namespace Drupal\reference_value_pair\Plugin\Field\FieldFormatter;
 
 use Drupal\Core\Field\FieldItemListInterface;
-use Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase;
 use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
 
 /**
@@ -17,7 +16,7 @@ use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
  *   }
  * )
  */
-class ReferenceValueTemplateFormatter extends EntityReferenceFormatterBase {
+class ReferenceValueTemplateFormatter extends ReferenceValueFormatterBase {
 
   /**
    * {@inheritdoc}
@@ -37,9 +36,12 @@ class ReferenceValueTemplateFormatter extends EntityReferenceFormatterBase {
         '#theme' => 'reference_value_pair_formatter',
         '#item' => $items[$delta],
         '#entity' => $entity,
+        '#label' => $entity ? $entity->label() : $items[$delta]->_label,
         '#element' => $element,
       );
-      $elements[$delta]['#cache']['tags'] = $entity->getCacheTags();
+      if ($entity !== NULL) {
+        $elements[$delta]['#cache']['tags'] = $entity->getCacheTags();
+      }
     }
 
     return $elements;
