Include 'Grant' entity custom fields in buildCustomProfile()
Created by: webmaster-cses-org-uk
This PR is intended to fix https://github.com/JMAConsulting/biz.jmaconsulting.grantapplications/issues/175.
The root cause is that core does not retrieve custom data for the 'Grant' entity type by default when getting profile fields, and does not consider 'Grant' a special profile type (such as 'Participant' or 'Event') when filtering / matching a profile against the contact type.
Before
Custom fields created for the grant itself do not render correctly in confirmation emails. (Note: contact custom fields are OK)
After
Custom fields created for the grant itself do render correctly in confirmation emails.
Technical Details
Update buildCustomProfile() so that custom data for the Grant entity type is retrieved alongside contact data.
Two changes to make this work:
- Always match if profile type is 'Grant' so that it will be processed in
CRM_Grant_BAO_GrantApplicationPage::buildCustomProfile()
- Explicitly define the custom data types to be considered by
CRM_Core_BAO_CustomField::getFields()
, which is ultimately called byCRM_Core_BAO_UFGroup::getFields()
. Without defining$ctype
, the filter defaults to contact entity types only. We now pass in a list of entity types comprising the default list with 'Grant' added.
Testing
Tested and working on CiviCRM 5.37.0 - see screenshots.