From cd83df5c575520f56f8def198f17ff6cffb415cb Mon Sep 17 00:00:00 2001
From: benjamin
Date: Mon, 16 Dec 2024 13:23:40 +0000
Subject: [PATCH 1/9] rename is_multiple to allow_is_multiple in cg_extends
---
CRM/Core/BAO/CustomGroup.php | 30 ++++++++++++++---------------
CRM/Custom/Form/Group.php | 2 +-
templates/CRM/Custom/Form/Group.tpl | 4 ++--
3 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php
index ce33dbc2802b..62e5e709f2a6 100644
--- a/CRM/Core/BAO/CustomGroup.php
+++ b/CRM/Core/BAO/CustomGroup.php
@@ -2137,7 +2137,7 @@ public static function getEntityFromExtends(string $extends): string {
* Returns a mix of hard-coded array and `cg_extend_objects` OptionValues.
* - 'id' return key (maps to `cg_extend_objects.value`).
* - 'grouping' key refers to the entity field used to select a sub-type.
- * - 'is_multiple' (@internal, not returned by getFields.loadOptions) (maps to `cg_extend_objects.filter`)
+ * - 'allow_is_multiple' (@internal, not returned by getFields.loadOptions) (maps to `cg_extend_objects.filter`)
* controls whether the entity supports multi-record custom groups.
* - 'table_name' (@internal, not returned by getFields.loadOptions) (maps to `cg_extend_objects.name`).
* We don't return it as the 'name' in getFields because it is not always unique (since contact types are pseudo-entities).
@@ -2151,14 +2151,14 @@ public static function getCustomGroupExtendsOptions() {
'label' => ts('Activities'),
'grouping' => 'activity_type_id',
'table_name' => 'civicrm_activity',
- 'is_multiple' => FALSE,
+ 'allow_is_multiple' => FALSE,
],
[
'id' => 'Relationship',
'label' => ts('Relationships'),
'grouping' => 'relationship_type_id',
'table_name' => 'civicrm_relationship',
- 'is_multiple' => FALSE,
+ 'allow_is_multiple' => FALSE,
],
// TODO: Move to civi_contribute extension (example: OptionValue_cg_extends_objects_grant.mgd.php)
[
@@ -2166,21 +2166,21 @@ public static function getCustomGroupExtendsOptions() {
'label' => ts('Contributions'),
'grouping' => 'financial_type_id',
'table_name' => 'civicrm_contribution',
- 'is_multiple' => FALSE,
+ 'allow_is_multiple' => FALSE,
],
[
'id' => 'ContributionRecur',
'label' => ts('Recurring Contributions'),
'grouping' => NULL,
'table_name' => 'civicrm_contribution_recur',
- 'is_multiple' => FALSE,
+ 'allow_is_multiple' => FALSE,
],
[
'id' => 'Group',
'label' => ts('Groups'),
'grouping' => NULL,
'table_name' => 'civicrm_group',
- 'is_multiple' => FALSE,
+ 'allow_is_multiple' => FALSE,
],
// TODO: Move to civi_member extension (example: OptionValue_cg_extends_objects_grant.mgd.php)
[
@@ -2188,7 +2188,7 @@ public static function getCustomGroupExtendsOptions() {
'label' => ts('Memberships'),
'grouping' => 'membership_type_id',
'table_name' => 'civicrm_membership',
- 'is_multiple' => FALSE,
+ 'allow_is_multiple' => FALSE,
],
// TODO: Move to civi_event extension (example: OptionValue_cg_extends_objects_grant.mgd.php)
[
@@ -2196,14 +2196,14 @@ public static function getCustomGroupExtendsOptions() {
'label' => ts('Events'),
'grouping' => 'event_type_id',
'table_name' => 'civicrm_event',
- 'is_multiple' => FALSE,
+ 'allow_is_multiple' => FALSE,
],
[
'id' => 'Participant',
'label' => ts('Participants'),
'grouping' => NULL,
'table_name' => 'civicrm_participant',
- 'is_multiple' => FALSE,
+ 'allow_is_multiple' => FALSE,
],
// TODO: Move to civi_pledge extension (example: OptionValue_cg_extends_objects_grant.mgd.php)
[
@@ -2211,14 +2211,14 @@ public static function getCustomGroupExtendsOptions() {
'label' => ts('Pledges'),
'grouping' => NULL,
'table_name' => 'civicrm_pledge',
- 'is_multiple' => FALSE,
+ 'allow_is_multiple' => FALSE,
],
[
'id' => 'Address',
'label' => ts('Addresses'),
'grouping' => NULL,
'table_name' => 'civicrm_address',
- 'is_multiple' => FALSE,
+ 'allow_is_multiple' => FALSE,
],
// TODO: Move to civi_campaign extension (example: OptionValue_cg_extends_objects_grant.mgd.php)
[
@@ -2226,14 +2226,14 @@ public static function getCustomGroupExtendsOptions() {
'label' => ts('Campaigns'),
'grouping' => 'campaign_type_id',
'table_name' => 'civicrm_campaign',
- 'is_multiple' => FALSE,
+ 'allow_is_multiple' => FALSE,
],
[
'id' => 'Contact',
'label' => ts('Contacts'),
'grouping' => NULL,
'table_name' => 'civicrm_contact',
- 'is_multiple' => TRUE,
+ 'allow_is_multiple' => TRUE,
],
];
// `CustomGroup.extends` stores contact type as if it were an entity.
@@ -2243,7 +2243,7 @@ public static function getCustomGroupExtendsOptions() {
'label' => $contactInfo['label'],
'grouping' => 'contact_sub_type',
'table_name' => 'civicrm_contact',
- 'is_multiple' => TRUE,
+ 'allow_is_multiple' => TRUE,
'icon' => $contactInfo['icon'],
];
}
@@ -2255,7 +2255,7 @@ public static function getCustomGroupExtendsOptions() {
'label' => $ogValue['label'],
'grouping' => $ogValue['grouping'] ?? NULL,
'table_name' => $ogValue['name'],
- 'is_multiple' => !empty($ogValue['filter']),
+ 'allow_is_multiple' => !empty($ogValue['filter']),
];
}
foreach ($options as &$option) {
diff --git a/CRM/Custom/Form/Group.php b/CRM/Custom/Form/Group.php
index 0c1dd26f6c24..74436dd0f71d 100644
--- a/CRM/Custom/Form/Group.php
+++ b/CRM/Custom/Form/Group.php
@@ -167,7 +167,7 @@ public function buildQuickForm() {
// Assign data for use by js chain-selects
$this->assign('entityColumnIdOptions', $entityColumnIdOptions);
// List of entities that allow `is_multiple`
- $this->assign('allowMultiple', array_column($extendsOptions, 'is_multiple', 'id'));
+ $this->assign('allowMultiple', array_column($extendsOptions, 'allow_is_multiple', 'id'));
// Used by warnDataLoss
$this->assign('defaultSubtypes', $this->_values['extends_entity_column_value'] ?? []);
// Used to initially hide selects with no options
diff --git a/templates/CRM/Custom/Form/Group.tpl b/templates/CRM/Custom/Form/Group.tpl
index 2064a1d32965..7aa8180d3da9 100644
--- a/templates/CRM/Custom/Form/Group.tpl
+++ b/templates/CRM/Custom/Form/Group.tpl
@@ -83,7 +83,7 @@ CRM.$(function($) {
const {/literal}
$form = $('form.{$form.formClass}'),
entityColumnIdOptions = {$entityColumnIdOptions|@json_encode},
- allMultiple = {$allowMultiple|@json_encode},
+ allowMultiple = {$allowMultiple|@json_encode},
defaultSubtypes = {$defaultSubtypes|@json_encode};
{literal}
let tabWithTableOption;
@@ -151,7 +151,7 @@ CRM.$(function($) {
// When changing or initializing the primary `extends` field
function handleExtends() {
- let multiAllowed = $(this).val() && allMultiple[$(this).val()];
+ let multiAllowed = $(this).val() && allowMultiple[$(this).val()];
if (multiAllowed) {
$('tr.field-style, tr.field-is_multiple', $form).show();
From ce1c91452278f2c4797140fe8b7d81136195fb7b Mon Sep 17 00:00:00 2001
From: benjamin
Date: Mon, 16 Dec 2024 13:24:48 +0000
Subject: [PATCH 2/9] allow_is_multiple for Event CustomGroups
---
CRM/Core/BAO/CustomGroup.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php
index 62e5e709f2a6..c91ef28109df 100644
--- a/CRM/Core/BAO/CustomGroup.php
+++ b/CRM/Core/BAO/CustomGroup.php
@@ -2196,7 +2196,7 @@ public static function getCustomGroupExtendsOptions() {
'label' => ts('Events'),
'grouping' => 'event_type_id',
'table_name' => 'civicrm_event',
- 'allow_is_multiple' => FALSE,
+ 'allow_is_multiple' => TRUE,
],
[
'id' => 'Participant',
From 2a763315acc174ecb0a04d1152eba4d6fac9afce Mon Sep 17 00:00:00 2001
From: benjamin
Date: Mon, 16 Dec 2024 13:25:22 +0000
Subject: [PATCH 3/9] update Custom Group create is_multiple help text to not
assume contact, remove old report related guidance
---
templates/CRM/Custom/Form/Group.hlp | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/templates/CRM/Custom/Form/Group.hlp b/templates/CRM/Custom/Form/Group.hlp
index 3e9df92edeaa..71f314beb121 100644
--- a/templates/CRM/Custom/Form/Group.hlp
+++ b/templates/CRM/Custom/Form/Group.hlp
@@ -43,17 +43,10 @@
{ts}Allow Multiple Records{/ts}
{/htxt}
{htxt id="id-is_multiple"}
-
{ts}Checking this box allows you to enter multiple sets of values for a given contact.{/ts}
+
{ts}Checking this box allows you to enter multiple sets of values for a given record.{/ts}
{ts}EXAMPLE: When creating a set of custom fields used to collect Employment History - you might have fields for Job Title, Start Date, End Date, and Reason for Leaving. Checking the "multiple records" box allows you to collect information for multiple jobs.{/ts}
{ts}You can also set the maximum number of records which can be recorded per contact. Using the previous example, you might only want data for the three most recent jobs.{/ts}
-
{ts 1=$importMultipleURL}Use the Multi-value Custom Data Import tool to import data into multiple record custom fields (contact records must already exist).{/ts}
-
- {ts}CAUTION: The following features are NOT available for custom fields in 'multiple record' custom set:{/ts}
-
-
{ts}They can not be Exported{/ts}
-
{ts}If they are included in a report as a display column, only the first set of values are shown.{/ts}
-
-
+
{ts 1=$importMultipleURL}Use the Multi-value Custom Data Import tool to import data into multiple record custom fields (the parent records should already exist).{/ts}