Skip to end of metadata
Go to start of metadata

Steps currently required to make custom groups support a new object

Core And Custom Group Forms
  • Fixing xml / schema to change enum for extends column of civicrm_custom_group table. File - xml/schema/Core/CustomGroup.xml.
  • Fixing upgrade to address above schema change.
  • Writing helper functions or CRM/{$Component}/PseudoConstant.php to generate types for new extend object. For example Contribution object has types as Donation, Event Fee etc.
  • Adding to custom group extends list in CRM/Core/SelectValues::customGroupExtends().
  • Adding "object -to-> table" mapping in CRM/Core/BAO/CustomGroup::mapTableName().
  • Fixing custom group forms to list / populate / save new object and its types - CRM/Custom/Form/Group.php.
  • Fixing display of custom groups extending new object in CRM/Custom/Page/Group.php
Injecting New Custom Fields In A Form And Supporting CRUD Operation
  • Supporting CRUD operation for custom fields related to new object, for a form using -
    CRM_Custom_Form_Customdata::preProcess(),
    CRM_Custom_Form_Customdata::buildQuickForm(),
    CRM_Custom_Form_Customdata::setDefaultValues(),
    CRM_Core_BAO_CustomField::postProcess() to format the custom fields in proper format.
  • If your new object has a BAO file example CRM/$Object/BAO$Object.php, the create file in same function should be made responsible for saving custom field values (if any) with the help of CRM_Core_BAO_CustomValueTable::store() method.
  • Fixing form tpl to inject CRM/Custom/Form/CustomData.tpl and js file CRM/common/customData.tpl.
Adding Support To Searches
  • If there is a component advanced search pane in advanced search that you would like your custom fields rendered into, CRM/{$Component}/Form/Search.php is the file generally, where you could add support for injecting / building custom field forms.
  • If a component search is to be populated with custom fields related to new object, CRM/{$Component}/Form/Search{$component}.php is generally the file, you would be adding support to.
  • Make sure CRM/{$Component}/BAO/Query.php for new object supports querying custom fields.
Adding Support To Profiles
  • Fixing profile form to list custom fields corresponding to related object in CRM/UF/Form/Field.php.
  • If required making sure profile supports add / update / view of these custom fields.
Adding Support To Import / Export
  • Fixing import / export to reflect fields for this new custom object.
  • Needs more investigation ...

Suggestions To Make Custom Fields Auto Support A New Object

Core And Custom Group Forms
  • Remove enum constraint from extends column of custom_group table. Make it a varchar.
  • Store the custom group extends list along with types for every object, and entity_table (for object to table mapping) in option_group / value table.
  • Fixing CRM/Core/SelectValues::customGroupExtends() method to retrieve 'custom group extends' list from option group / value table.
  • Fixing CRM/Custom/Form/Group.php (and page) to retrieve type list from option group / value table.
  • Fixing custom group schema handler to look for object to table mapping in option group / value table.
Labels:

Creative Commons License
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-Share Alike 3.0 United States Licence.