Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure custom fields properties are assigned to the template #22139

Merged
merged 1 commit into from
Nov 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CRM/Core/BAO/CustomGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,7 @@ public static function createTable($group) {
* @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 = [];

Expand Down Expand Up @@ -1822,8 +1822,12 @@ public static function formatGroupTree(&$groupTree, $groupCount = 1, &$form = NU
$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']) &&
Expand Down
6 changes: 3 additions & 3 deletions templates/CRM/Custom/Form/Edit/CustomField.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
+--------------------------------------------------------------------+
*}

{if !empty($element.help_pre)}
{if $element.help_pre}
<tr class="custom_field-help-pre-row {$element.element_name}-row-help-pre">
<td>&nbsp;</td>
<td class="html-adjust description">{$element.help_pre}</td>
Expand All @@ -17,7 +17,7 @@
{if isset($element.options_per_line) and $element.options_per_line != 0 }
<tr class="custom_field-row {$element.element_name}-row">
<td
class="label">{$formElement.label}{if !empty($element.help_post)}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$element.label}{/if}</td>
class="label">{$formElement.label}{if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$element.label}{/if}</td>
<td class="html-adjust">
{assign var="count" value="1"}
<table class="form-layout-compressed" style="margin-top: -0.5em;">
Expand Down Expand Up @@ -45,7 +45,7 @@
{else}
<tr class="custom_field-row {$element.element_name}-row">
<td class="label">{$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}
</td>
<td class="html-adjust">
{$formElement.html}&nbsp;
Expand Down