*/
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.
*/
$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.
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);
</tr>
{/if}
<tr>
- <td colspan="2"><div id="customData"></div></td>
+ <td colspan="2">{include file="CRM/common/customDataBlock.tpl"}</td>
</tr>
{if NOT $activityTypeFile}
<tr class="crm-case-activity-form-block-details">
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
{if $action eq 1 or $action eq 2}
- {*include custom data js file*}
- {include file="CRM/common/customData.tpl"}
{literal}
<script type="text/javascript">
- CRM.$(function($) {
- var doNotNotifyAssigneeFor = {/literal}{$doNotNotifyAssigneeFor|@json_encode}{literal};
- $('#activity_type_id').change(function() {
- if ($.inArray($(this).val(), doNotNotifyAssigneeFor) != -1) {
- $('#notify_assignee_msg').hide();
- }
- else {
- $('#notify_assignee_msg').show();
- }
+ CRM.$(function($) {
+ var doNotNotifyAssigneeFor = {/literal}{$doNotNotifyAssigneeFor|@json_encode}{literal};
+ $('#activity_type_id').change(function() {
+ if ($.inArray($(this).val(), doNotNotifyAssigneeFor) != -1) {
+ $('#notify_assignee_msg').hide();
+ }
+ else {
+ $('#notify_assignee_msg').show();
+ }
+ });
});
-
- {/literal}
- {if $customDataSubType}
- CRM.buildCustomData( '{$customDataType}', {$customDataSubType} );
- {else}
- CRM.buildCustomData( '{$customDataType}' );
- {/if}
- {literal}
- });
</script>
{/literal}
{/if}
<tr class="crm-case-form-block-custom_data">
<td colspan="2">
- <div id="customData"></div>
+ {include file="CRM/common/customDataBlock.tpl"}
</td>
</tr>
</table>
{/if}
-{if $action eq 1}
- {*include custom data js file*}
- {include file="CRM/common/customData.tpl"}
- {literal}
- <script type="text/javascript">
- CRM.$(function($) {
- var customDataSubType = $('#case_type_id').val();
- if ( customDataSubType ) {
- CRM.buildCustomData( {/literal}'{$customDataType}'{literal}, customDataSubType );
- } else {
- CRM.buildCustomData( {/literal}'{$customDataType}'{literal} );
- }
- });
- </script>
- {/literal}
-{/if}
-
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
</div>