From 85eed448a1b8d45f72e8b910742a497b6b2f1eda Mon Sep 17 00:00:00 2001 From: Samuel Vanhove Date: Wed, 18 Oct 2023 17:39:47 -0400 Subject: [PATCH] dev/core#4703 --- CRM/Group/Form/Edit.php | 9 ++++--- templates/CRM/Group/Form/GroupsCommon.tpl | 30 +++++------------------ 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/CRM/Group/Form/Edit.php b/CRM/Group/Form/Edit.php index 772cda0786..7f615f322e 100644 --- a/CRM/Group/Form/Edit.php +++ b/CRM/Group/Form/Edit.php @@ -201,6 +201,8 @@ class CRM_Group_Form_Edit extends CRM_Core_Form { } } + $parentGroupIds = explode(',', $this->_groupValues['parents']); + $defaults['parents'] = $parentGroupIds; if (empty($defaults['parents'])) { $defaults['parents'] = CRM_Core_BAO_Domain::getGroupId(); } @@ -402,9 +404,6 @@ WHERE title = %1 $parentGroups[$parentGroupId] = $groupNames[$parentGroupId]; if (array_key_exists($parentGroupId, $groupNames)) { $parentGroupElements[$parentGroupId] = $groupNames[$parentGroupId]; - $form->addElement('checkbox', "remove_parent_group_$parentGroupId", - $groupNames[$parentGroupId] - ); } } } @@ -412,6 +411,8 @@ WHERE title = %1 if (isset($form->_id)) { $potentialParentGroupIds = CRM_Contact_BAO_GroupNestingCache::getPotentialCandidates($form->_id, $groupNames); + // put back current groups because they are selected by default + $potentialParentGroupIds = array_merge($potentialParentGroupIds, $parentGroupIds); } else { $potentialParentGroupIds = array_keys($groupNames); @@ -431,7 +432,7 @@ WHERE title = %1 else { $required = FALSE; } - $form->add('select', 'parents', ts('Add Parent'), $parentGroupSelectValues, $required, ['class' => 'crm-select2', 'multiple' => TRUE]); + $form->add('select', 'parents', ts('Parents'), $parentGroupSelectValues, $required, ['class' => 'crm-select2', 'multiple' => TRUE]); } return $parentGroups; diff --git a/templates/CRM/Group/Form/GroupsCommon.tpl b/templates/CRM/Group/Form/GroupsCommon.tpl index 3b5e5f0080..590afb4f44 100644 --- a/templates/CRM/Group/Form/GroupsCommon.tpl +++ b/templates/CRM/Group/Form/GroupsCommon.tpl @@ -7,30 +7,12 @@ | and copyright information, see https://civicrm.org/licensing | +--------------------------------------------------------------------+ *} -{*CRM-14190*} -{if $parent_groups|@count > 0 || !empty($form.parents.html)} -

{ts}Parent Groups{/ts} {help id="id-group-parent" file="CRM/Group/Page/Group.hlp"}

- {if $parent_groups|@count > 0} - - - - - {foreach from=$parent_groups item=cgroup key=group_id} - {assign var="element_name" value="remove_parent_group_"|cat:$group_id} - - - - {/foreach} -
  {$form.$element_name.html} {$form.$element_name.label}
-
- {/if} - - - - - -
      {$form.parents.label}{$form.parents.html|crmAddClass:huge}
-{/if} + + + + + +
      {$form.parents.label}{$form.parents.html|crmAddClass:huge}
{if array_key_exists('organization_id', $form)}

{ts}Associated Organization{/ts} {help id="id-group-organization" file="CRM/Group/Page/Group.hlp"}

-- 2.25.1