From 1dc69ec3245de3288b8d5fddcc1751618942869c Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 29 Nov 2021 14:30:24 +1300 Subject: [PATCH] Ensure separation,tag are assigned to the template --- CRM/Activity/Form/Activity.php | 13 +++++++++++++ CRM/Core/Form.php | 4 ++++ templates/CRM/Activity/Form/Activity.tpl | 4 ++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CRM/Activity/Form/Activity.php b/CRM/Activity/Form/Activity.php index ac0ba84bec..79a557629b 100644 --- a/CRM/Activity/Form/Activity.php +++ b/CRM/Activity/Form/Activity.php @@ -515,6 +515,19 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { } } + /** + * Get any smarty elements that may not be present in the form. + * + * To make life simpler for smarty we ensure they are set to null + * rather than unset. This is done at the last minute when $this + * is converted to an array to be assigned to the form. + * + * @return array + */ + public function getOptionalQuickFormElements(): array { + return ['separation', 'tag']; + } + /** * Set default values for the form. * diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 68574f3aa6..fff2e0ac49 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -1072,6 +1072,10 @@ class CRM_Core_Form extends HTML_QuickForm_Page { /** * Add an optional element to the optional elements array. * + * These elements are assigned as empty (null) variables if + * there is no real field - allowing smarty to use them without + * notices. + * * @param string $elementName */ public function addOptionalQuickFormElement(string $elementName): void { diff --git a/templates/CRM/Activity/Form/Activity.tpl b/templates/CRM/Activity/Form/Activity.tpl index 6be2f9672c..4718ad5739 100644 --- a/templates/CRM/Activity/Form/Activity.tpl +++ b/templates/CRM/Activity/Form/Activity.tpl @@ -63,7 +63,7 @@ - {if !empty($form.separation)} + {if $form.separation} {$form.separation.label} {$form.separation.html} {help id="separation"} @@ -156,7 +156,7 @@ {$form.result.label}{$form.result.html} {/if} - {if !empty($form.tag.html)} + {if $form.tag} {$form.tag.label} -- 2.25.1