From 85cc9cc4fd8ef02e0ba64b194ec4f9b3d127147a Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 31 Mar 2023 21:38:18 -0400 Subject: [PATCH] CustomField - Show filters when editing EntityReference fields --- CRM/Custom/Form/Field.php | 4 +++- templates/CRM/Custom/Form/Field.tpl | 22 ++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CRM/Custom/Form/Field.php b/CRM/Custom/Form/Field.php index d7856a5bfb..a9d5230e4d 100644 --- a/CRM/Custom/Form/Field.php +++ b/CRM/Custom/Form/Field.php @@ -868,7 +868,9 @@ AND option_group_id = %2"; $filter = 'action=lookup&group=' . implode(',', $params['group_id']); } } - $params['filter'] = $filter; + if ($params['data_type'] !== 'EntityReference') { + $params['filter'] = $filter; + } // fix for CRM-316 $oldWeight = NULL; diff --git a/templates/CRM/Custom/Form/Field.tpl b/templates/CRM/Custom/Form/Field.tpl index 05df6d9dd1..184d63079a 100644 --- a/templates/CRM/Custom/Form/Field.tpl +++ b/templates/CRM/Custom/Form/Field.tpl @@ -66,9 +66,20 @@ {$form.filter.label} {$form.filter.html} -   {ts}Filter by Group{/ts} + {ts}Filter by Group{/ts}
- {ts}Filter contact search results for this field using Contact get API parameters. EXAMPLE: To list Students in group 3:{/ts} "action=get&group=3&contact_sub_type=Student" {docURL page="dev/api"} + + {ts}Filter contact search results for this field using Contact get API parameters. EXAMPLE: To list Students in group 3:{/ts} + action=get&group=3&contact_sub_type=Student + {docURL page="dev/api"} + + + {ts}Filter search results for this field using API-style parameters{/ts} + (field=value&another_field=val1,val2).
+ {ts}EXAMPLE (Contact entity): To list Students in "Volunteers" or "Supporters" groups:{/ts} + contact_sub_type=Student&groups:name=Volunteers,Supporters + {docURL page="dev/api"} +
@@ -229,8 +240,8 @@ $('#filter_selected').val(setSelected.slice(1)); } if (setSelected == '#Advance') { - $('#contact_reference_group').hide( ); - $('#field_advance_filter').show( ); + $('#contact_reference_group, .api4-filter-info').hide(); + $('#field_advance_filter, .api3-filter-info').show(); } else { $('#field_advance_filter').hide( ); $('#contact_reference_group').show( ); @@ -249,6 +260,9 @@ if (dataType === 'ContactReference') { toggleContactRefFilter(); + } else if (dataType === 'EntityReference') { + $('#field_advance_filter, .api4-filter-info').show(); + $('#contact_reference_group, .api3-filter-info').hide(); } else { $('#field_advance_filter, #contact_reference_group', $form).hide(); } -- 2.25.1