From 920e4372b94c701fea7a4d5d9da402eeabdbe7c4 Mon Sep 17 00:00:00 2001
From: AKHIL BABU <61542-AkhilBabu@users.noreply.drupalcode.org>
Date: Sun, 19 Feb 2023 06:13:09 +0000
Subject: [PATCH] Issue #3325447 by sujan.shrestha: Warning Upon creating new
 transaction

---
 src/Entity/EtTransaction.php | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/Entity/EtTransaction.php b/src/Entity/EtTransaction.php
index 44460df..3bb3f04 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();
+        }
       }
     }
 
-- 
GitLab