From 1e2b1b3716b119f9403094c8c6b0bfe6c4f93779 Mon Sep 17 00:00:00 2001
From: lkmorlan <lkmorlan@493050.no-reply.drupal.org>
Date: Mon, 17 Jun 2019 12:05:31 -0400
Subject: [PATCH] Issue #3060718 by Liam Morland: Make Webform default_nid work
 when entity_token is enabled

---
 fillpdf.module | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fillpdf.module b/fillpdf.module
index 810a071..f6b7da8 100644
--- a/fillpdf.module
+++ b/fillpdf.module
@@ -810,12 +810,14 @@ function fillpdf_load_entities($fillpdf_info, $nids, $webform_array, $uc_order_i
   // If no nid is given, and Entity API is disabled, use the default nid as a
   // classic node. (If Entity API is enabled, we'll handle it as an entity later
   // on in this function.)
-  if (!$entity_mode && !empty($fillpdf_info->default_nid) && empty($nids) && empty($webform_array)) {
+  if (empty($fillpdf_info->default_entity_type) && !empty($fillpdf_info->default_nid) && empty($nids) && empty($webform_array)) {
     $default_node = node_load($fillpdf_info->default_nid);
     if ($default_node) {
       // Default node is a non-webform node.
       if (empty($default_node->webform)) {
-        $context['nodes'][] = $default_node;
+        if (!$entity_mode) {
+          $context['nodes'][] = $default_node;
+        }
       }
       // Default node is a webform.
       else {
@@ -825,6 +827,8 @@ function fillpdf_load_entities($fillpdf_info, $nids, $webform_array, $uc_order_i
             'node' => $default_node,
           ),
         );
+        // Since this is handled here, prevent it from being processed as an entity later.
+        $entity_mode = FALSE;
       }
     }
   }
-- 
GitLab