trait CRM_Core_Form_EntityFormTrait {
+ /**
+ * The entity subtype ID (eg. for Relationship / Activity)
+ *
+ * @var int
+ */
+ protected $_entitySubTypeId;
+
/**
* Get entity fields for the entity to be added to the form.
*
public function getEntityId() {
return $this->_id;
}
+
+ /**
+ * Get the entity subtype ID being edited
+ *
+ * @param $subTypeId
+ *
+ * @return int|null
+ */
+ public function getEntitySubTypeId($subTypeId) {
+ if ($subTypeId) {
+ return $subTypeId;
+ }
+ return $this->_entitySubTypeId;
+ }
+
/**
* If the custom data is in the submitted data (eg. added via ajax loaded form) add to form.
*/
public static function addToForm(&$form, $subType = NULL, $subName = NULL, $groupCount = 1) {
$entityName = $form->getDefaultEntity();
$entityID = $form->getEntityId();
+ $entitySubType = $form->getEntitySubTypeId($subType);
// when custom data is included in this page
if (!empty($_POST['hidden_custom'])) {
- self::preProcess($form, $subName, $subType, $groupCount, $entityName, $entityID);
+ self::preProcess($form, $subName, $entitySubType, $groupCount, $entityName, $entityID);
self::buildQuickForm($form);
self::setDefaultValues($form);
}
// need to assign custom data type and subtype to the template
$form->assign('customDataType', $entityName);
- $form->assign('customDataSubType', $subType);
+ $form->assign('customDataSubType', $entitySubType);
$form->assign('entityID', $entityID);
}