This documentation relates to CiviCRM version 3.2. It's not maintained anymore.
Current version of documentation.

Custom Data Group and Custom Field APIs

Skip to end of metadata
Go to start of metadata

This page refers to outdated version of CiviCRM. Check current version of documentation.


Documentation Search


CiviCRM 3.2 Documentation

Support and Participation

Developer Resources


CiviCRM book!

Make sure to check out Understanding CiviCRM as well! You can also support this project by ordering a hard copy.

Custom Data APIs

civicrm_custom_group_create($params)

Availability: v1.8
Latest Format Modifications: v2.1

CRM allows you to define groups of custom properties ('custom fields') for most core classes (Contact', 'Individual', 'Household', 'Organization', 'Location', 'Address', 'Contribution', 'Activity', 'Relationship', 'Group', 'Membership', 'Participant', 'Event', 'Grant', 'Pledge'). Each custom field must belong to an custom group (which can contain one or more fields). Use this API to create a new custom data group.

Parameters:

  • 'params' (array) Associative array of property name/value pairs to insert in group.
    • Group Title ($params['title']) is required.
    • You must pass either Class Name ($params['class_name']) OR Extends (($params['extends']) with the class name included as the first item.
    • To create a custom group which extends a specific "type" of class - include the type identifier as the second item in $params['extends'].
      EXAMPLE: To create a group which extends Participant with Role = Volunteer (role id = 2, using default Participant Role data):
    • This API automatically munges the group's visible 'title' into the internally used 'name'. If you don't want this behavior - explicitly specify a 'name' parameter..
    Returns:
  • Array of newly created custom_group properties

civicrm_custom_group_delete($params)

Availability: v1.8

Use this API to delete a Custom Group.

Parameters:*'params' (array) id of the group to be deleted.

Returns:

  • null if successfull, array of CRM_Core_Error otherwise

civicrm_custom_field_create( $params )

Availability: v1.8
Latest Format Modifications: v2.1

Defines 'custom field' within a group.

Parameters:

  • 'params' (array) Associative array of property name/value pairs to create new custom field.
    • Field 'label','custom_group_id', 'html_type', and 'data_type' are required.
    • For Radio, Select, Multi-Select or Checkbox fields, you can define the multiple choice options by including arrays for 'option_value', 'option_label', 'option_weight' as shown below.
    • 'data_type' can be one of the following
      • String (Alphanumeric)
      • Int (Integer)
      • Float (Number)
      • Money (Money)
      • Memo (Note)
      • Date (Date)
      • Boolean (Yes or No)
      • StateProvince (State/Province)
      • Country (Country)
      • File (File)
      • Link (Link)
      • ContactReference (Contact Reference)
     

Returns:

  • Array of newly created custom_field

civicrm_custom_field_delete( $params )

Availability: v1.8

Use this API to delete a Custom Field.

Parameters:

  • 'params' (array) id of the field to be deleted.

Returns:

  • null if successfull, array of CRM_Core_Error otherwise
  • Delete Custom Field
  • Delete Option Value Fields
Labels
  • None

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.