Ensure separation,tag are assigned to the template
authorEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 29 Nov 2021 01:30:24 +0000 (14:30 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 29 Nov 2021 01:43:36 +0000 (14:43 +1300)
CRM/Activity/Form/Activity.php
CRM/Core/Form.php
templates/CRM/Activity/Form/Activity.tpl

index ac0ba84beca7e78320c463ea2a30a1b89477bf20..79a557629bf5aa3376c75532bccd6f6f6232a90b 100644 (file)
@@ -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.
    *
index 68574f3aa6af7f2e14cf2cb68e60251e99853665..fff2e0ac4949fe83644423e439a08d8671e8f582 100644 (file)
@@ -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 {
index 6be2f9672c42b1f16ad9f249cab16cd4c49db52c..4718ad5739170b24468a12fb9c23e18c7b42c867 100644 (file)
@@ -63,7 +63,7 @@
     </td>
   </tr>
 
-  {if !empty($form.separation)}
+  {if $form.separation}
     <tr class="crm-activity-form-block-separation crm-is-multi-activity-wrapper">
       <td class="label">{$form.separation.label}</td>
       <td>{$form.separation.html} {help id="separation"}</td>
     <td class="label">{$form.result.label}</td><td class="view-value">{$form.result.html}</td>
   </tr>
   {/if}
-  {if !empty($form.tag.html)}
+  {if $form.tag}
   <tr class="crm-activity-form-block-tag">
     <td class="label">{$form.tag.label}</td>
     <td class="view-value">