Fix wonkyness if contribution page includes a profile with both groups & tags
authoreileen <emcnaughton@wikimedia.org>
Fri, 2 Feb 2024 05:04:47 +0000 (18:04 +1300)
committereileen <emcnaughton@wikimedia.org>
Fri, 2 Feb 2024 05:15:22 +0000 (18:15 +1300)
CRM/Contact/Form/Edit/TagsAndGroups.php
templates/CRM/UF/Form/Fields.tpl

index 4beab414fdc62e6f3408b83a7bcc2a028d646542..1ea0955697dd18b0b98a2b3c997b6e0127e7d1f2 100644 (file)
@@ -58,7 +58,6 @@ class CRM_Contact_Form_Edit_TagsAndGroups {
     $groupElementType = 'checkbox',
     $public = FALSE
   ) {
-    $tagGroup = [];
     $form->addExpectedSmartyVariable('type');
     $form->addOptionalQuickFormElement('group');
     // NYSS 5670
@@ -131,6 +130,7 @@ class CRM_Contact_Form_Edit_TagsAndGroups {
     $form->assign('groupElementType', $groupElementType ?? NULL);
 
     if ($type & self::TAG) {
+      $tagGroup = [];
       $tags = CRM_Core_BAO_Tag::getColorTags('civicrm_contact');
 
       if (!empty($tags)) {
@@ -141,7 +141,7 @@ class CRM_Contact_Form_Edit_TagsAndGroups {
       $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
       CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', $contactId, FALSE, TRUE);
     }
-    $form->assign('tagGroup', $tagGroup);
+    $form->assign('tagGroup', $tagGroup ?? NULL);
   }
 
   /**
index b1dd3af32e12d2355f69b55362e090f584ddcf3d..f697dc71ae1d216110951a96b153e43503bd657d 100644 (file)
 
           {if $profileFieldName eq 'email_greeting' or  $profileFieldName eq 'postal_greeting' or $profileFieldName eq 'addressee'}
             {include file="CRM/Profile/Form/GreetingType.tpl"}
+          {elseif $profileFieldName eq 'tag'}
+          <table class="form-layout-compressed{if $context EQ 'profile'} crm-profile-tagsandgroups{/if}">
+            <tr>
+              <td>
+            <div class="crm-section tag-section">
+              {if !empty($title)}{$form.tag.label}<br>{/if}
+              {$form.tag.html}
+            </div>
+              </td>
+            </tr>
+          </table>
           {elseif ($profileFieldName eq 'group' && $form.group) || ($profileFieldName eq 'tag' && $form.tag)}
-            {include file="CRM/Contact/Form/Edit/TagsAndGroups.tpl" type=$profileFieldName title=null context="profile"}
+            <table class="form-layout-compressed{if $context EQ 'profile'} crm-profile-tagsandgroups{/if}">
+              <tr>
+                <td>
+            {if $groupElementType eq 'select'}
+              <div class="crm-section group-section">
+                {if $title}{$form.group.label}<br>{/if}
+                {$form.group.html}
+              </div>
+            {else}
+              {foreach key=key item=item from=$tagGroup.group}
+                <div class="group-wrapper">
+                  {$form.group.$key.html}
+                  {if $item.description}
+                    <div class="description">{$item.description}</div>
+                  {/if}
+                </div>
+              {/foreach}
+            {/if}
+                </td>
+              </tr>
+            </table>
           {elseif array_key_exists('is_datetime_field', $field) && $field.is_datetime_field && $action & 4}
             <span class="crm-frozen-field">
               {$formElement.value|crmDate:$field.smarty_view_format}