From 21fced3b2b374d3e26aedcc7672d9a21273672d8 Mon Sep 17 00:00:00 2001 From: atif-shaikh Date: Tue, 18 Nov 2014 11:28:22 +0530 Subject: [PATCH] CRM-15595 - Individual sub-type custom fields don't appear in online event registration https://issues.civicrm.org/jira/browse/CRM-15595 --- CRM/Event/Form/ManageEvent/Registration.php | 3 +-- CRM/UF/Page/ProfileEditor.php | 5 ++++- js/jquery/jquery.crmProfileSelector.js | 7 ++++++- js/model/crm.uf.js | 8 +++++++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CRM/Event/Form/ManageEvent/Registration.php b/CRM/Event/Form/ManageEvent/Registration.php index cdf24e26bb..95f4e5c67a 100644 --- a/CRM/Event/Form/ManageEvent/Registration.php +++ b/CRM/Event/Form/ManageEvent/Registration.php @@ -376,8 +376,7 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent 'profileEntities' => array(), ); - $configs['allowCoreTypes'][] = 'Contact'; - $configs['allowCoreTypes'][] = 'Individual'; + $configs['allowCoreTypes'] = array_merge(array('Contact', 'Individual'), CRM_Contact_BAO_ContactType::subTypes('Individual')); $configs['allowCoreTypes'][] = 'Participant'; //CRM-15427 $id = CRM_Utils_Request::retrieve( 'id' , 'Integer' ); diff --git a/CRM/UF/Page/ProfileEditor.php b/CRM/UF/Page/ProfileEditor.php index 441e6b7e2e..0991bd7894 100644 --- a/CRM/UF/Page/ProfileEditor.php +++ b/CRM/UF/Page/ProfileEditor.php @@ -31,6 +31,7 @@ class CRM_UF_Page_ProfileEditor extends CRM_Core_Page { 'is_active' => 1, 'rowCount' => 1000, // FIXME )), + 'contactSubTypes' => CRM_Contact_BAO_ContactType::subTypes(), 'profilePreviewKey' => CRM_Core_Key::get('CRM_UF_Form_Inline_Preview', TRUE), ); }) @@ -195,7 +196,9 @@ class CRM_UF_Page_ProfileEditor extends CRM_Core_Page { case 'Individual': case 'Organization': case 'Household': - if ($field['field_type'] != $extends && $field['field_type'] != 'Contact') { + if ($field['field_type'] != $extends && $field['field_type'] != 'Contact' + //CRM-15595 check if subtype + && !in_array($field['field_type'], CRM_Contact_BAO_ContactType::subTypes($extends))) { continue 2; } break; diff --git a/js/jquery/jquery.crmProfileSelector.js b/js/jquery/jquery.crmProfileSelector.js index 8bb4a51e4f..9dc5cf8d7b 100644 --- a/js/jquery/jquery.crmProfileSelector.js +++ b/js/jquery/jquery.crmProfileSelector.js @@ -61,7 +61,12 @@ else { civiComponent = 'Contribution'; } - CRM.alert(ts('The selected profile is using a custom field which is not assigned to the '+civiComponent+' being configured.'),ts('Warning')); + CRM.alert( + ts('The selected profile is using a custom field which is not assigned to the "%1" being configured.', { + 1: civiComponent + }), + ts('Warning') + ); } var view = new CRM.ProfileSelector.View({ ufGroupId: $select.val(), diff --git a/js/model/crm.uf.js b/js/model/crm.uf.js index b28f876140..cdb0ad24a9 100644 --- a/js/model/crm.uf.js +++ b/js/model/crm.uf.js @@ -104,7 +104,13 @@ case 'Case': return 'case_1'; default: - throw "Cannot guess entity name for field_type=" + field_type; + if (!$.isEmptyObject(CRM.contactSubTypes) && + ($.inArray(field_type,CRM.contactSubTypes) > -1)) { + return 'contact_1'; + } + else { + throw "Cannot guess entity name for field_type=" + field_type; + } } } -- 2.25.1