From 2c024dc655533d8f607fd3d39dea3c739b46789b Mon Sep 17 00:00:00 2001 From: "Matthew Wire (MJW Consulting)" Date: Fri, 11 Jan 2019 18:55:07 +0000 Subject: [PATCH] Don't call getEntitySubTypeId if a subType is not defined --- CRM/Custom/Form/CustomData.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CRM/Custom/Form/CustomData.php b/CRM/Custom/Form/CustomData.php index f4528ceac3..532a11ef81 100644 --- a/CRM/Custom/Form/CustomData.php +++ b/CRM/Custom/Form/CustomData.php @@ -55,7 +55,13 @@ class CRM_Custom_Form_CustomData { public static function addToForm(&$form, $subType = NULL, $subName = NULL, $groupCount = 1) { $entityName = $form->getDefaultEntity(); $entityID = $form->getEntityId(); - $entitySubType = $form->getEntitySubTypeId($subType); + // FIXME: If the form has been converted to use entityFormTrait then getEntitySubTypeId() will exist. + // However, if it is only partially converted (ie. we've switched customdata to use CRM_Custom_Form_CustomData) + // it won't, so we check if we have a subtype before calling the function. + $entitySubType = NULL; + if ($subType) { + $entitySubType = $form->getEntitySubTypeId($subType); + } // when custom data is included in this page if (!empty($_POST['hidden_custom'])) { -- 2.25.1