diff --git a/src/Entity/EtTransaction.php b/src/Entity/EtTransaction.php index 44460df54ddd5f0fb3f2a4a921ed4432f09599c1..3bb3f04c54cd27f4bc982e24dd186da32741e193 100644 --- a/src/Entity/EtTransaction.php +++ b/src/Entity/EtTransaction.php @@ -680,10 +680,12 @@ class EtTransaction extends ContentEntityBase implements EtTransactionInterface */ public function preSave(EntityStorageInterface $storage) { parent::preSave($storage); - foreach ($this->choice as $choice_item) { - if ($choice_item->entity && $choice_item->entity->needsSaving()) { - $choice_item->entity->save(); - $choice_item->target_id = $choice_item->entity->id(); + if (!empty($this->choice)) { + foreach ($this->choice as $choice_item) { + if ($choice_item->entity && $choice_item->entity->needsSaving()) { + $choice_item->entity->save(); + $choice_item->target_id = $choice_item->entity->id(); + } } }