From db773960bda90518ecdabde074025945adefeb72 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 8 Nov 2021 11:26:15 +1300 Subject: [PATCH] Ensure beginHookFormElements is assigned This ensures the variable is assigned & hence does not enotice with escape on output --- CRM/Core/Form.php | 13 +++++++++++++ templates/CRM/Form/body.tpl | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index fce332f774..9aff42aa6c 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -253,6 +253,18 @@ class CRM_Core_Form extends HTML_QuickForm_Page { 'color', ]; + /** + * Variables smarty expects to have set. + * + * We ensure these are assigned (value = NULL) when Smarty is instantiated in + * order to avoid e-notices / having to use empty or isset in the template layer. + * + * @var string[] + */ + public $expectedSmartyVariables = [ + 'beginHookFormElements', + ]; + /** * Constructor for the basic form page. * @@ -297,6 +309,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { // let the constructor initialize this, should happen only once if (!isset(self::$_template)) { self::$_template = CRM_Core_Smarty::singleton(); + self::$_template->ensureVariablesAreAssigned($this->expectedSmartyVariables); } // Workaround for CRM-15153 - give each form a reasonably unique css class $this->addClass(CRM_Utils_System::getClassName($this)); diff --git a/templates/CRM/Form/body.tpl b/templates/CRM/Form/body.tpl index a34e7a835c..b834269024 100644 --- a/templates/CRM/Form/body.tpl +++ b/templates/CRM/Form/body.tpl @@ -32,7 +32,7 @@ {/if} {* Add all the form elements sent in by the hook - used by civiDiscount and a few other extensions *} -{if !empty($beginHookFormElements)} +{if $beginHookFormElements} {foreach from=$beginHookFormElements key=dontCare item=hookFormElement} -- 2.25.1
{$form.$hookFormElement.label}{$form.$hookFormElement.html}