Don't call getEntitySubTypeId if a subType is not defined
authorMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Fri, 11 Jan 2019 18:55:07 +0000 (18:55 +0000)
committerMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Fri, 11 Jan 2019 18:55:07 +0000 (18:55 +0000)
CRM/Custom/Form/CustomData.php

index f4528ceac3e09a70a5b9a7c6e404bae47c87febc..532a11ef8181bf8a0eb7f9904c5f51cae32ba40e 100644 (file)
@@ -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'])) {