/**
* Store and return an array of all active custom fields.
*
- * @param string $customDataType type of Custom Data
+ * @param string $customDataType type of Custom Data; empty is a synonym for "all contact data types"
* @param boolean $showAll If true returns all fields (includes disabled fields)
* @param boolean $inline If true returns all inline fields (includes disabled fields)
* @param int $customDataSubType Custom Data sub type value
$checkPermission = TRUE
) {
if (empty($customDataType)) {
- throw new CRM_Core_Exception("Cannot lookup fields for blank entity");
+ $customDataType = array('Contact', 'Individual', 'Organization', 'Household');
}
if ($customDataType && !is_array($customDataType)) {
}
}
- if (empty($extends)) {
- // $customDataType did not include any customizable/extendable entities.
+ if (!empty($customDataType) && empty($extends)) {
+ // $customDataType specified a filter, but there is no corresponding SQL ($extends)
self::$_importFields[$cacheKey] = array();
return self::$_importFields[$cacheKey];
}
$field = self::getFieldObject($fieldId);
+ // Custom field HTML should indicate group+field name
+ $groupName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $field->custom_group_id);
+ $dataCrmCustomVal = $groupName.':'.$field->name;
+ $dataCrmCustomAttr = 'data-crm-custom="'.$dataCrmCustomVal.'"';
+ $field->attributes .= $dataCrmCustomAttr;
+
// Fixed for Issue CRM-2183
if ($field->html_type == 'TextArea' && $search) {
$field->html_type = 'Text';
break;
case 'TextArea':
- $attributes = '';
+ $attributes = $dataCrmCustomAttr;
if ($field->note_rows) {
$attributes .= 'rows=' . $field->note_rows;
}
'timeFormat' => $field->time_format,
'startOffset' => $field->start_date_years,
'endOffset' => $field->end_date_years,
+ 'data-crm-custom' => $dataCrmCustomVal,
)
);
'timeFormat' => $field->time_format,
'startOffset' => $field->start_date_years,
'endOffset' => $field->end_date_years,
+ 'data-crm-custom' => $dataCrmCustomVal,
)
);
}
'timeFormat' => $field->time_format,
'startOffset' => $field->start_date_years,
'endOffset' => $field->end_date_years,
+ 'data-crm-custom' => $dataCrmCustomVal,
));
}
break;
$qf->add('select', $elementName, $label,
array(
'' => ts('- select -')) + $selectOption,
- $useRequired && !$search
+ $useRequired && !$search,
+ $dataCrmCustomAttr
);
break;
'size' => 5,
'style' => '',
'class' => 'advmultiselect',
+ 'data-crm-custom' => $dataCrmCustomVal,
)
);
) {
$selectOption['CiviCRM_OP_OR'] = ts('Select to match ANY; unselect to match ALL');
}
- $qf->addElement('select', $elementName, $label, $selectOption, array('size' => '5', 'multiple'));
+ $qf->addElement('select', $elementName, $label, $selectOption, array('size' => '5', 'multiple', 'data-crm-custom' => $dataCrmCustomVal));
if ($useRequired && !$search) {
$qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
);
$check = array();
foreach ($customOption as $v => $l) {
- $check[] = &$qf->addElement('advcheckbox', $v, NULL, $l);
+ $check[] = &$qf->addElement('advcheckbox', $v, NULL, $l, array('data-crm-custom' => $dataCrmCustomVal));
}
if ($search &&
count($check) > 1
) {
- $check[] = &$qf->addElement('advcheckbox', 'CiviCRM_OP_OR', NULL, ts('Check to match ANY; uncheck to match ALL'));
+ $check[] = &$qf->addElement('advcheckbox', 'CiviCRM_OP_OR', NULL, ts('Check to match ANY; uncheck to match ALL'), array('data-crm-custom' => $dataCrmCustomVal));
}
$qf->addGroup($check, $elementName, $label);
if ($useRequired && !$search) {
//Add State
$stateOption = array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvince();
$qf->add('select', $elementName, $label, $stateOption,
- $useRequired && !$search
+ $useRequired && !$search,
+ $dataCrmCustomAttr
);
break;
//Add Multi-select State/Province
$stateOption = CRM_Core_PseudoConstant::stateProvince();
- $qf->addElement('select', $elementName, $label, $stateOption, array('size' => '5', 'multiple'));
+ $qf->addElement('select', $elementName, $label, $stateOption, array('size' => '5', 'multiple', 'data-crm-custom' => $dataCrmCustomVal));
if ($useRequired && !$search) {
$qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
}
//Add Country
$countryOption = array('' => ts('- select -')) + CRM_Core_PseudoConstant::country();
$qf->add('select', $elementName, $label, $countryOption,
- $useRequired && !$search
+ $useRequired && !$search,
+ $dataCrmCustomAttr
);
break;
case 'Multi-Select Country':
//Add Country
$countryOption = CRM_Core_PseudoConstant::country();
- $qf->addElement('select', $elementName, $label, $countryOption, array('size' => '5', 'multiple'));
+ $qf->addElement('select', $elementName, $label, $countryOption, array('size' => '5', 'multiple', 'data-crm-custom' => $dataCrmCustomVal));
if ($useRequired && !$search) {
$qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
}
break;
case 'RichTextEditor':
- $attributes = array('rows' => $field->note_rows, 'cols' => $field->note_columns);
+ $attributes = array('rows' => $field->note_rows, 'cols' => $field->note_columns, 'data-crm-custom' => $dataCrmCustomVal);
if ($field->text_length) {
$attributes['maxlength'] = $field->text_length;
}
array(
'onfocus' => "if (!this.value) { this.value='http://';} else return false",
'onblur' => "if ( this.value == 'http://') { this.value='';} else return false",
+ 'data-crm-custom' => $dataCrmCustomVal,
),
$useRequired && !$search
);
if ($value) {
$display = ts('Yes');
}
- elseif ($value === '0') {
+ elseif ((string)$value === '0') {
$display = ts('No');
}
}
$display = $value;
}
}
-
return $display ? $display : $value;
}
//get the custom fields for the entity
//subtype and basic type
$customDataSubType = NULL;
+ if (is_array($customFieldExtend)) {
+ $customFieldExtend = $customFieldExtend[0];
+ }
+
if (in_array($customFieldExtend,
CRM_Contact_BAO_ContactType::subTypes()
)) {
list($tableName, $columnName, $groupID) = self::getTableColumnGroup($customFieldId);
- if (is_array($customFieldExtend)) {
- $customFieldExtend = $customFieldExtend[0];
- }
if (!$customValueId &&
// we always create new entites for is_multiple unless specified
!$customFields[$customFieldId]['is_multiple'] &&