}
// when custom data is included in this page
+ $this->assign('cid', $this->_currentlyViewedContactId);
if (!empty($_POST['hidden_custom'])) {
// We need to set it in the session for the code below to work.
// CRM-3014
$element = &$this->add('select', 'activity_type_id', ts('Activity Type'),
['' => '- ' . ts('select') . ' -'] + $this->_fields['followup_activity_type_id']['attributes'],
FALSE, [
- 'onchange' => "CRM.buildCustomData( 'Activity', this.value );",
+ 'onchange' => "CRM.buildCustomData( 'Activity', this.value, false, false, false, false, false, false, {$this->_currentlyViewedContactId});",
'class' => 'crm-select2 required',
]
);
* e.g Student for contact type
* @param null|string $subName value in civicrm_custom_group.extends_entity_column_id
* @param null|int $groupCount number of entities that could have custom data
+ * @param null|int $contact_id contact ID associated with the custom data.
*
* @throws \CRM_Core_Exception
*/
- public static function addToForm(&$form, $subType = NULL, $subName = NULL, $groupCount = 1) {
+ public static function addToForm(&$form, $subType = NULL, $subName = NULL, $groupCount = 1, $contact_id = NULL) {
$entityName = $form->getDefaultEntity();
$entityID = $form->getEntityId();
// FIXME: If the form has been converted to use entityFormTrait then getEntitySubTypeId() will exist.
$form->assign('customDataType', $entityName);
$form->assign('customDataSubType', $entitySubType);
$form->assign('entityID', $entityID);
+ $form->assign('cid', $contact_id);
}
/**
*/
class CRM_Custom_Form_CustomDataByType extends CRM_Core_Form {
+ /**
+ * Contact ID associated with the Custom Data
+ *
+ * @var int
+ */
+ public $_contactID = NULL;
+
/**
* Preprocess function.
*/
$this->_subName = CRM_Utils_Request::retrieve('subName', 'String');
$this->_groupCount = CRM_Utils_Request::retrieve('cgcount', 'Positive');
$this->_entityId = CRM_Utils_Request::retrieve('entityID', 'Positive');
+ $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive');
$this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive');
$this->_onlySubtype = CRM_Utils_Request::retrieve('onlySubtype', 'Boolean');
$this->_action = CRM_Utils_Request::retrieve('action', 'Alphanumeric');
{literal}
<script type="text/javascript">
(function($) {
- CRM.buildCustomData = function (type, subType, subName, cgCount, groupID, isMultiple, onlySubtype) {
+ CRM.buildCustomData = function (type, subType, subName, cgCount, groupID, isMultiple, onlySubtype, cid) {
var dataUrl = CRM.url('civicrm/custom', {type: type}),
prevCount = 1,
fname = '#customData',
dataUrl += '&qf=' + '{$qfKey}';
{/if}
{if $action}
- dataUrl += '&action=' + '{$action}';
+ dataUrl += '&action=' + '{$action}';
{/if}
{literal}
+ if (cid) {
+ dataUrl += '&cid=' + cid;
+ }
if (!cgCount) {
cgCount = 1;
<div id="customData"></div>
{*include custom data js file*}
{include file="CRM/common/customData.tpl"}
+ {assign var='cid' value=$cid|default:'false'}
{literal}
<script type="text/javascript">
CRM.$(function($) {
{/literal}
{if $customDataSubType}
- CRM.buildCustomData('{$customDataType}', {$customDataSubType});
+ CRM.buildCustomData('{$customDataType}', {$customDataSubType}, false, false, false, false, false, {$cid});
{else}
- CRM.buildCustomData('{$customDataType}');
+ CRM.buildCustomData('{$customDataType}', false, false, false, false, false, false, {$cid});
{/if}
{literal}
});