Avoid e-notices on pages with tabs
authorBradley Taylor <hello@brad-taylor.co.uk>
Sat, 5 Mar 2022 15:26:43 +0000 (15:26 +0000)
committerBradley Taylor <hello@brad-taylor.co.uk>
Sat, 5 Mar 2022 15:26:43 +0000 (15:26 +0000)
CRM/Core/Form.php
CRM/Core/Page.php
CRM/Core/Smarty.php

index 88ae11e9be1eaa4df791a561b45142eb0478814c..ae31027817d832671e07c05ec3518928bff540ce 100644 (file)
@@ -719,7 +719,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
     // our ensured variables get blown away, so we need to set them even if
     // it's already been initialized.
     self::$_template->ensureVariablesAreAssigned($this->expectedSmartyVariables);
-
+    self::$_template->addExpectedTabHeaderKeys();
   }
 
   /**
index 4194e9bda745fc8723da13dbe115797fd587c827..7f9e785610f990585dcbd0bdeeedfb050e5db909 100644 (file)
@@ -199,6 +199,8 @@ class CRM_Core_Page {
     $pageTemplateFile = $this->getHookedTemplateFileName();
     self::$_template->assign('tplFile', $pageTemplateFile);
 
+    self::$_template->addExpectedTabHeaderKeys();
+
     // invoke the pagRun hook, CRM-3906
     CRM_Utils_Hook::pageRun($this);
 
index bcd9c69d91bddd7e9aa8cce5f5d4d1e6f94c0805..c7476e9b94f425b50df82749d35b01f8582cfdf2 100644 (file)
@@ -202,6 +202,26 @@ class CRM_Core_Smarty extends Smarty {
     }
   }
 
+  /**
+   * Avoid e-notices on pages with tabs,
+   * by ensuring tabHeader items contain the necessary keys
+   */
+  public function addExpectedTabHeaderKeys(): void {
+    $defaults = [
+      'class' => '',
+      'extra' => '',
+      'icon' => FALSE,
+      'count' => FALSE,
+      'template' => FALSE,
+    ];
+
+    $tabs = $this->get_template_vars('tabHeader');
+    foreach ((array) $tabs as $i => $tab) {
+      $tabs[$i] = array_merge($defaults, $tab);
+    }
+    $this->assign('tabHeader', $tabs);
+  }
+
   /**
    * Fetch a template (while using certain variables)
    *