Merge pull request #22948 from pradpnayak/fixfatalerror3
[civicrm-core.git] / CRM / Core / Form.php
index 8ab1c22a0815003ec58b8fdd462d6d48fcbddcb6..6d59fd537f61a5baeb38737d22faecabf078c84e 100644 (file)
@@ -611,11 +611,11 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
   /**
    * This virtual function is used to set the default values of various form elements.
    *
-   * @return array|NULL
+   * @return array
    *   reference to the array of default values
    */
   public function setDefaultValues() {
-    return NULL;
+    return [];
   }
 
   /**
@@ -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();
   }
 
   /**
@@ -1113,6 +1113,18 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
     $this->expectedSmartyVariables[] = $elementName;
   }
 
+  /**
+   * Add an expected smarty variable to the array.
+   *
+   * @param array $elementNames
+   */
+  public function addExpectedSmartyVariables(array $elementNames): void {
+    foreach ($elementNames as $elementName) {
+      // Duplicates don't actually matter....
+      $this->addExpectedSmartyVariable($elementName);
+    }
+  }
+
   /**
    * Render form and return contents.
    *
@@ -1574,7 +1586,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
    * Adds a select based on field metadata.
    * TODO: This could be even more generic and widget type (select in this case) could also be read from metadata
    * Perhaps a method like $form->bind($name) which would look up all metadata for named field
-   * @param $name
+   * @param string $name
    *   Field name to go on the form.
    * @param array $props
    *   Mix of html attributes and special properties, namely.