From 8d90652e0235ee9b92a242eb83b330b649b4276f Mon Sep 17 00:00:00 2001 From: Alice Frumin Date: Thu, 6 Sep 2018 14:08:45 -0400 Subject: [PATCH] dev/core#362 fixing contact reference fields on On Behalf Profiles search and select functionality --- CRM/Core/BAO/CustomField.php | 8 ++++++-- templates/CRM/Custom/Form/ContactReference.tpl | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index 6fc3fe7d49..ba33cb9fec 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -1062,8 +1062,12 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { $element = $qf->add('text', $elementName, $label, $attributes, $useRequired && !$search); $urlParams = "context=customfield&id={$field->id}"; - - $customUrls[$elementName] = CRM_Utils_System::url('civicrm/ajax/contactref', + $idOfelement = $elementName; + // dev/core#362 if in an onbehalf profile clean up the name to get rid of square brackets that break the select 2 js + if (strpos($elementName, '[') && strpos($elementName, ']')) { + $idOfelement = substr(substr($elementName, (strpos($elementName, '[') + 1)), 0, -1); + } + $customUrls[$idOfelement] = CRM_Utils_System::url('civicrm/ajax/contactref', $urlParams, FALSE, NULL, FALSE ); diff --git a/templates/CRM/Custom/Form/ContactReference.tpl b/templates/CRM/Custom/Form/ContactReference.tpl index ab464693eb..a5eb9a3b8c 100644 --- a/templates/CRM/Custom/Form/ContactReference.tpl +++ b/templates/CRM/Custom/Form/ContactReference.tpl @@ -28,7 +28,8 @@ {literal}