Skip to content

Commit

Permalink
Merge pull request #22892 from braders/ensure-tabheader-keys-are-assi…
Browse files Browse the repository at this point in the history
…gned

Avoid e-notices on pages with tabs
  • Loading branch information
demeritcowboy authored Mar 6, 2022
2 parents bde31ce + 42aa581 commit 0868278
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CRM/Core/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ public function buildForm() {
// 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();
}

/**
Expand Down
2 changes: 2 additions & 0 deletions CRM/Core/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ public function run() {
$pageTemplateFile = $this->getHookedTemplateFileName();
self::$_template->assign('tplFile', $pageTemplateFile);

self::$_template->addExpectedTabHeaderKeys();

// invoke the pagRun hook, CRM-3906
CRM_Utils_Hook::pageRun($this);

Expand Down
20 changes: 20 additions & 0 deletions CRM/Core/Smarty.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,26 @@ public function ensureVariablesAreAssigned(array $variables): void {
}
}

/**
* 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)
*
Expand Down

0 comments on commit 0868278

Please sign in to comment.