commit ffaa8bc603b9901b196c6e1660d97b13c009826d
Author: Bojan Zivanovic <bojanz@gmail.com>
Date:   Mon Apr 4 11:24:15 2016 +0200

    Use #entity to access the IEF form element value.

diff --git a/src/Element/InlineEntityForm.php b/src/Element/InlineEntityForm.php
index 23356ed..736239c 100644
--- a/src/Element/InlineEntityForm.php
+++ b/src/Element/InlineEntityForm.php
@@ -119,7 +119,6 @@ class InlineEntityForm extends RenderElement {
   public static function validateEntityForm(&$entity_form, FormStateInterface $form_state) {
     $inline_form_handler = static::getInlineFormHandler($entity_form['#entity_type']);
     $inline_form_handler->entityFormValidate($entity_form, $form_state);
-    $form_state->setValueForElement($entity_form, $entity_form['#entity']);
   }
 
   /**
diff --git a/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php b/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php
index 6cfa422..a56c113 100644
--- a/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php
+++ b/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php
@@ -538,6 +538,9 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
     $parents = array_merge($form['#parents'], [$field_name, 'form']);
     $ief_id = sha1(implode('-', $parents));
     $this->setIefId($ief_id);
+    // The $form structure is different from the form value structure.
+    $element_parents = array_merge($form['#parents'], [$field_name, 'widget', 'form']);
+    $element = NestedArray::getValue($form, $parents);
 
     $inline_entity_form_state = $form_state->get('inline_entity_form');
     if (isset($inline_entity_form_state[$this->getIefId()])) {
@@ -555,8 +558,7 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
       if (empty($values['entities']) && !empty($values['form'])) {
         // @todo Do the same for reference forms.
         if ($values['form'] == 'add') {
-          $add_form_parents = array_merge($parents, ['inline_entity_form']);
-          $entity = $form_state->getValue($add_form_parents);
+          $entity = $element['inline_entity_form']['#entity'];
           $values['entities'][] = ['entity' => $entity];
         }
       }
diff --git a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php
index 68c1320..a4ba943 100644
--- a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php
+++ b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\inline_entity_form\Plugin\Field\FieldWidget;
 
+use Drupal\Component\Utility\NestedArray;
 use Drupal\Core\Field\FieldDefinitionInterface;
 use Drupal\Core\Field\FieldItemListInterface;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
@@ -118,10 +119,11 @@ class InlineEntityFormSimple extends InlineEntityFormBase {
     $field_name = $this->fieldDefinition->getName();
     $parents = array_merge($form['#parents'], [$field_name]);
     $submitted_values = $form_state->getValue($parents);
+    $element = NestedArray::getValue($form, $parents);
     $values = [];
     foreach ($items as $delta => $value) {
       /** @var \Drupal\Core\Entity\EntityInterface $entity */
-      $entity = $submitted_values[$delta]['inline_entity_form'];
+      $entity = $element['widget'][$delta]['inline_entity_form']['#entity'];
       $weight = isset($submitted_values[$delta]['_weight']) ? $submitted_values[$delta]['_weight'] : 0;
       $values[$weight] = ['entity' => $entity];
     }
diff --git a/tests/modules/inline_entity_form_test/src/IefEditTest.php b/tests/modules/inline_entity_form_test/src/IefEditTest.php
index 11b54a2..44f13ff 100644
--- a/tests/modules/inline_entity_form_test/src/IefEditTest.php
+++ b/tests/modules/inline_entity_form_test/src/IefEditTest.php
@@ -41,7 +41,7 @@ class IefEditTest extends FormBase {
    * {@inheritdoc}
    */
   public function submitForm(array &$form, FormStateInterface $form_state) {
-    $entity = $form_state->getValue('inline_entity_form');
+    $entity = $form['inline_entity_form']['#entity'];
     drupal_set_message(t('Created @entity_type @label.', ['@entity_type' => $entity->getEntityType()->getLabel(), '@label' => $entity->label()]));
   }
 
diff --git a/tests/modules/inline_entity_form_test/src/IefTest.php b/tests/modules/inline_entity_form_test/src/IefTest.php
index ec097a8..d18f0db 100644
--- a/tests/modules/inline_entity_form_test/src/IefTest.php
+++ b/tests/modules/inline_entity_form_test/src/IefTest.php
@@ -39,7 +39,7 @@ class IefTest extends FormBase {
    * {@inheritdoc}
    */
   public function submitForm(array &$form, FormStateInterface $form_state) {
-    $entity = $form_state->getValue('inline_entity_form');
+    $entity = $form['inline_entity_form']['#entity'];
     drupal_set_message(t('Created @entity_type @label.', ['@entity_type' => $entity->getEntityType()->getLabel(), '@label' => $entity->label()]));
   }
 
