Documentation

CRM_Custom_Form_CustomData
in package

Deprecated class no longer used in core.

since 5.72 will be removed around 5.92

Table of Contents

Methods

addToForm()  : mixed
Generic wrapper to add custom data to a form via a single line in preProcess.
buildQuickForm()  : mixed
preProcess()  : mixed
setDefaultValues()  : array<string|int, mixed>
setGroupTree()  : array<string|int, mixed>
Add the group data as a formatted array to the form.

Methods

addToForm()

Generic wrapper to add custom data to a form via a single line in preProcess.

public static addToForm(CRM_Core_Form &$form[, null|string $entitySubType = NULL ][, null|string $subName = NULL ][, null|int $groupCount = 1 ][, null|int $contact_id = NULL ]) : mixed
  • preferred code now is to add to ensure the tpl loads custom data using the ajax template & add code to buildForm() like this
if ($this->isSubmitted()) {
  $this->addCustomDataFieldsToForm('Membership', array_filter([
  'id' => $this->getMembershipID(),
  'membership_type_id' => $this->getSubmittedValue('membership_type_id')
]));
}

$this->getDefaultEntity() must be defined for the form class for this to work.

If the postProcess form cannot use the api & instead uses a BAO function it will need. $params['custom'] = CRM_Core_BAO_CustomField::postProcess($submitted, $this->_id, $this->getDefaultEntity());

Parameters
$form : CRM_Core_Form
$entitySubType : null|string = NULL

values stored in civicrm_custom_group.extends_entity_column_value e.g Student for contact type

$subName : null|string = NULL

value in civicrm_custom_group.extends_entity_column_id

$groupCount : null|int = 1

number of entities that could have custom data

$contact_id : null|int = NULL

contact ID associated with the custom data.

Tags
throws
CRM_Core_Exception

preProcess()

public static preProcess(CRM_Core_Form &$form[, null|string $extendsEntityColumn = NULL ][, null|string $subType = NULL ][, null|int $groupCount = NULL ][, null $type = NULL ][, null|int $entityID = NULL ][, null $onlySubType = NULL ][, bool $isLoadFromCache = TRUE ]) : mixed

see https://github.com/civicrm/civicrm-core/pull/29241 for preferred approach - basically

  1. at the tpl layer use CRM/common/customDataBlock.tpl
  2. to make the fields available for postProcess if ($this->isSubmitted()) { $this->addCustomDataFieldsToForm('FinancialAccount'); }
  3. pass getSubmittedValues() to CRM_Core_BAO_CustomField::postProcess($this->getSubmittedValues(), $this->_id, 'FinancialAccount'); to ensure any money or number fields are handled for localisation
Parameters
$form : CRM_Core_Form
$extendsEntityColumn : null|string = NULL

Additional filter on the type of custom data to retrieve - e.g for participant data this could be a value representing role.

$subType : null|string = NULL
$groupCount : null|int = NULL
$type : null = NULL
$entityID : null|int = NULL
$onlySubType : null = NULL
$isLoadFromCache : bool = TRUE
Tags
throws
CRM_Core_Exception

setGroupTree()

Add the group data as a formatted array to the form.

public static setGroupTree(CRM_Core_Form &$form, string $subType, int $gid[, bool $onlySubType = NULL ][, bool $getCachedTree = TRUE ]) : array<string|int, mixed>

since 5.65 will be removed around 5.80.

Note this is only called from this class in core but it is called from the gdpr extension so rather than clean it up we will deprecate in place and stop calling from core. (Calling functions like this from extensions) is not supported but since we are aware of it we can deprecate rather than remove it).

Parameters
$form : CRM_Core_Form
$subType : string
$gid : int
$onlySubType : bool = NULL
$getCachedTree : bool = TRUE
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

        
On this page

Search results