From 1ac1a7d0cce7822fd21d57cad36b251eec5e4cf5 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 26 Nov 2021 15:46:38 +1300 Subject: [PATCH] Ensure custom fields properties are assigned to the template --- CRM/Core/BAO/CustomGroup.php | 6 +++++- templates/CRM/Custom/Form/Edit/CustomField.tpl | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index 2fa0d47b5f..0c48e87afe 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -1788,7 +1788,7 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, * @return array * @throws \CRM_Core_Exception */ - public static function formatGroupTree(&$groupTree, $groupCount = 1, &$form = NULL) { + public static function formatGroupTree($groupTree, $groupCount = 1, &$form = NULL) { $formattedGroupTree = []; $uploadNames = $formValues = []; @@ -1822,8 +1822,12 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, $formattedGroupTree[$key]['subtype'] = $value['subtype'] ?? NULL; $formattedGroupTree[$key]['max_multiple'] = $value['max_multiple'] ?? NULL; + // Properties that might have been filtered out but which + // should be present to avoid smarty e-notices. + $expectedProperties = ['options_per_line', 'help_pre', 'help_post']; // add field information foreach ($value['fields'] as $k => $properties) { + $properties = array_merge(array_fill_keys($expectedProperties, 'NULL'), $properties); $properties['element_name'] = "custom_{$k}_-{$groupCount}"; if (isset($properties['customValue']) && !CRM_Utils_System::isNull($properties['customValue']) && diff --git a/templates/CRM/Custom/Form/Edit/CustomField.tpl b/templates/CRM/Custom/Form/Edit/CustomField.tpl index 7acd1de052..56accccaa5 100644 --- a/templates/CRM/Custom/Form/Edit/CustomField.tpl +++ b/templates/CRM/Custom/Form/Edit/CustomField.tpl @@ -8,7 +8,7 @@ +--------------------------------------------------------------------+ *} -{if !empty($element.help_pre)} +{if $element.help_pre}   {$element.help_pre} @@ -17,7 +17,7 @@ {if isset($element.options_per_line) and $element.options_per_line != 0 } {$formElement.label}{if !empty($element.help_post)}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$element.label}{/if} + class="label">{$formElement.label}{if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$element.label}{/if} {assign var="count" value="1"} @@ -45,7 +45,7 @@ {else}
{$formElement.label} - {if !empty($element.help_post)}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$element.label}{/if} + {if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$element.label}{/if} {$formElement.html}  -- 2.25.1