From cc3dbc01b3bc87721d4efa9d41bdf3f95332e507 Mon Sep 17 00:00:00 2001 From: "Matthew Wire (MJW Consulting)" Date: Mon, 7 Jan 2019 17:51:24 +0000 Subject: [PATCH] Convert case/case activity forms to standard customData template --- CRM/Case/Form/Case.php | 46 ++++++++++++++++++++++------ templates/CRM/Case/Form/Activity.tpl | 32 +++++++------------ templates/CRM/Case/Form/Case.tpl | 19 +----------- 3 files changed, 48 insertions(+), 49 deletions(-) diff --git a/CRM/Case/Form/Case.php b/CRM/Case/Form/Case.php index 9e3e2897c3..d8b2ae47ae 100644 --- a/CRM/Case/Form/Case.php +++ b/CRM/Case/Form/Case.php @@ -83,6 +83,36 @@ class CRM_Case_Form_Case extends CRM_Core_Form { */ public $_caseTypeId = NULL; + /** + * Explicitly declare the entity api name. + */ + public function getDefaultEntity() { + return 'Case'; + } + + /** + * Get the entity id being edited. + * + * @return int|null + */ + public function getEntityId() { + return $this->_caseId; + } + + /** + * Get the entity subtype ID being edited + * + * @param $subTypeId + * + * @return int|null + */ + public function getEntitySubTypeId($subTypeId) { + if ($subTypeId) { + return $subTypeId; + } + return $this->_caseTypeId; + } + /** * Build the form object. */ @@ -170,18 +200,15 @@ class CRM_Case_Form_Case extends CRM_Core_Form { $session = CRM_Core_Session::singleton(); $this->_currentUserId = $session->get('userID'); - //when custom data is included in this page + //Add activity custom data is included in this page CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_activityTypeId, 1, 'Activity'); $className = "CRM_Case_Form_Activity_{$this->_activityTypeFile}"; $className::preProcess($this); $activityGroupTree = $this->_groupTree; - // for case custom fields to populate with defaults - if (!empty($_POST['hidden_custom'])) { - $params = CRM_Utils_Request::exportValues(); - CRM_Custom_Form_CustomData::preProcess($this, NULL, CRM_Utils_Array::value('case_type_id', $params, $this->_caseTypeId), 1, 'Case', $this->_caseId); - CRM_Custom_Form_CustomData::buildQuickForm($this); - } + // Add case custom data to form + $caseTypeId = CRM_Utils_Array::value('case_type_id', CRM_Utils_Request::exportValues(), $this->_caseTypeId); + CRM_Custom_Form_CustomData::addToForm($this, $caseTypeId); // so that grouptree is not populated with case fields, since the grouptree is used // for populating activity custom fields. @@ -227,10 +254,9 @@ class CRM_Case_Form_Case extends CRM_Core_Form { return; } - //need to assign custom data type and subtype to the template - $this->assign('customDataType', 'Case'); - + // Add the activity custom data to the form CRM_Custom_Form_CustomData::buildQuickForm($this); + // we don't want to show button on top of custom form $this->assign('noPreCustomButton', TRUE); diff --git a/templates/CRM/Case/Form/Activity.tpl b/templates/CRM/Case/Form/Activity.tpl index aa8d78cb5c..fff7efa834 100644 --- a/templates/CRM/Case/Form/Activity.tpl +++ b/templates/CRM/Case/Form/Activity.tpl @@ -161,7 +161,7 @@ {/if} -
+ {include file="CRM/common/customDataBlock.tpl"} {if NOT $activityTypeFile} @@ -268,29 +268,19 @@
{include file="CRM/common/formButtons.tpl" location="bottom"}
{if $action eq 1 or $action eq 2} - {*include custom data js file*} - {include file="CRM/common/customData.tpl"} {literal} {/literal} {/if} diff --git a/templates/CRM/Case/Form/Case.tpl b/templates/CRM/Case/Form/Case.tpl index 08d2d004ed..fb000fbe79 100644 --- a/templates/CRM/Case/Form/Case.tpl +++ b/templates/CRM/Case/Form/Case.tpl @@ -115,7 +115,7 @@ -
+ {include file="CRM/common/customDataBlock.tpl"} @@ -124,23 +124,6 @@ {/if} -{if $action eq 1} - {*include custom data js file*} - {include file="CRM/common/customData.tpl"} - {literal} - - {/literal} -{/if} -
{include file="CRM/common/formButtons.tpl" location="bottom"}
-- 2.25.1