Add cid parameter in custom group form url & set it for Activity form
Overview
Custom group forms are usually loaded by AJAX, in the parent entities forms they extend from.
The class CRM_Custom_Form_CustomDataByType
is the one that manages custom group form, but doesn't contain the contact_id attribute which is essential for performing tasks such as set a default value based on Contact's data, validate values against Contact's data, etc.
Now a days, theses tasks are hard to code, and most of them must rely on JQuery scripts or too complex workarounds to be achieved
From https://github.com/civicrm/civicrm-core/pull/13191
Before
class CRM_Custom_Form_CustomDataByType
doesn't store contact_id value
After
class CRM_Custom_Form_CustomDataByType
stores contact_id value, which is sent by the parent Entity through url parameter cid (when is available)
Technical Details
The url is called from this function:
https://github.com/civicrm/civicrm-core/blob/master/templates/CRM/common/customData.tpl#L29
CRM.buildCustomData = function (type, subType, subName, cgCount, groupID, isMultiple, onlySubtype) {
var dataUrl = CRM.url('civicrm/custom', {type: type}),
prevCount = 1,
fname = '#customData',
storage = {};
. . . .
then there are 42 php/tpls files that use this function and must be adapted to send the cid when is available List of 42 files here
Comments
This is the first iteration of an incremental change that must be performed to adapt every Entity in CiviCRM.
MM discussion here