diff --git a/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php b/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php index f7b4e92..e347688 100644 --- a/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php +++ b/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php @@ -621,13 +621,6 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF /** @var \Drupal\Core\Entity\EntityInterface $entity */ $entity = $item['entity']; if (!empty($item['needs_save'])) { - $entity->save(); - } - if (!empty($item['delete'])) { - $entity->delete(); - unset($items[$delta]); - } - if (!empty($item['needs_save'])) { if ($entity instanceof RevisionableInterface) { $entity->setNewRevision(); // If a new revision is created, save the current user as revision author. @@ -640,6 +633,12 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF $entity->setRevisionUser(\Drupal::currentUser()); } } + $entity->save(); + $item['needs_save'] = FALSE; + } + if (!empty($item['delete'])) { + $entity->delete(); + unset($items[$delta]); } } }