Skip to content

Commit

Permalink
Merge pull request #22152 from eileenmcnaughton/n1
Browse files Browse the repository at this point in the history
[Smarty variables] [Activity form] Ensure separation,tag are assigned to the template
  • Loading branch information
colemanw authored Nov 29, 2021
2 parents b4e819c + 1dc69ec commit f03972e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
13 changes: 13 additions & 0 deletions CRM/Activity/Form/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,19 @@ public function preProcess() {
}
}

/**
* 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.
*
Expand Down
4 changes: 4 additions & 0 deletions CRM/Core/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,10 @@ public function setOptions($options) {
/**
* 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 {
Expand Down
4 changes: 2 additions & 2 deletions templates/CRM/Activity/Form/Activity.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -156,7 +156,7 @@
<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">
Expand Down

0 comments on commit f03972e

Please sign in to comment.