*
* @var int
*/
- protected $_entitySubTypeId;
+ protected $_entitySubTypeId = NULL;
/**
* Get entity fields for the entity to be added to the form.
/**
* Get the entity subtype ID being edited
*
- * @param $subTypeId
- *
* @return int|null
*/
- public function getEntitySubTypeId($subTypeId) {
- if ($subTypeId) {
- return $subTypeId;
- }
+ public function getEntitySubTypeId() {
return $this->_entitySubTypeId;
}
+ /**
+ * Set the entity subtype ID being edited
+ *
+ * @param $subTypeId
+ */
+ public function setEntitySubTypeId($subTypeId) {
+ $this->_entitySubTypeId = $subTypeId;
+ }
+
/**
* If the custom data is in the submitted data (eg. added via ajax loaded form) add to form.
*/
}
$customisableEntities = CRM_Core_SelectValues::customGroupExtends();
if (isset($customisableEntities[$this->getDefaultEntity()])) {
- CRM_Custom_Form_CustomData::addToForm($this);
+ CRM_Custom_Form_CustomData::addToForm($this, $this->getEntitySubTypeId());
}
}
* $params['custom'] = CRM_Core_BAO_CustomField::postProcess($submitted, $this->_id, $this->getDefaultEntity());
*
* @param CRM_Core_Form $form
- * @param null|string $subType values stored in civicrm_custom_group.extends_entity_column_value
+ * @param null|string $entitySubType values stored in civicrm_custom_group.extends_entity_column_value
* e.g Student for contact type
* @param null|string $subName value in civicrm_custom_group.extends_entity_column_id
* @param null|int $groupCount number of entities that could have custom data
*
* @throws \CRM_Core_Exception
*/
- public static function addToForm(&$form, $subType = NULL, $subName = NULL, $groupCount = 1, $contact_id = NULL) {
+ public static function addToForm(&$form, $entitySubType = NULL, $subName = NULL, $groupCount = 1, $contact_id = NULL) {
$entityName = $form->getDefaultEntity();
$entityID = $form->getEntityId();
- // FIXME: If the form has been converted to use entityFormTrait then getEntitySubTypeId() will exist.
- // However, if it is only partially converted (ie. we've switched customdata to use CRM_Custom_Form_CustomData)
- // it won't, so we check if we have a subtype before calling the function.
- $entitySubType = NULL;
- if ($subType) {
- $entitySubType = $form->getEntitySubTypeId($subType);
+ // If the form has been converted to use entityFormTrait then getEntitySubTypeId() will exist.
+ if (method_exists($form, 'getEntitySubTypeId') && empty($entitySubType)) {
+ $entitySubType = $form->getEntitySubTypeId();
}
if ($form->getAction() == CRM_Core_Action::VIEW) {