else {
// FIXME: This won't work with customFieldOptions hook
$attributes += array(
- 'entity' => 'option_value',
+ 'entity' => 'OptionValue',
'placeholder' => $placeholder,
'multiple' => $search,
'api' => array(
- 'params' => array('option_group_id' => $field->option_group_id),
+ 'params' => array('option_group_id' => $field->option_group_id, 'is_active' => 1),
),
);
$element = $qf->addEntityRef($elementName, $label, $attributes, $useRequired && !$search);
$value = CRM_Utils_Array::explodePadded($value);
}
// CRM-12989 fix
- if ($field['html_type'] == 'CheckBox') {
- CRM_Utils_Array::formatArrayKeys($value);
+ if ($field['html_type'] == 'CheckBox' && $value) {
+ $value = CRM_Utils_Array::convertCheckboxFormatToArray($value);
}
$display = is_array($value) ? implode(', ', $value) : (string) $value;
list($path) = CRM_Core_BAO_File::path($fileID, $entityId);
$fileHash = CRM_Core_BAO_File::generateFileHash($entityId, $fileID);
$url = CRM_Utils_System::url('civicrm/file',
- "reset=1&id=$fileID&eid=$contactID&fcs=$fileHash",
+ "reset=1&id=$fileID&eid=$entityId&fcs=$fileHash",
$absolute, NULL, TRUE, TRUE
);
$result['file_url'] = CRM_Utils_File::getFileURL($path, $fileType, $url);
$fileID,
'uri'
);
- $fileHash = CRM_Core_BAO_File::generateFileHash($entityId, $fileID);
+ $fileHash = CRM_Core_BAO_File::generateFileHash($contactID, $fileID);
$url = CRM_Utils_System::url('civicrm/file',
"reset=1&id=$fileID&eid=$contactID&fcs=$fileHash",
$absolute, NULL, TRUE, TRUE
* Get custom field ID from field/group name/title.
*
* @param string $fieldName Field name or label
- * @param string|null $groupTitle (Optional) Group name or label
+ * @param string|null $groupName (Optional) Group name or label
* @param bool $fullString Whether to return "custom_123" or "123"
*
* @return string|int|null
* @throws \CiviCRM_API3_Exception
*/
- public static function getCustomFieldID($fieldName, $groupTitle = NULL, $fullString = FALSE) {
- if (!isset(Civi::$statics['CRM_Core_BAO_CustomField'][$fieldName])) {
+ public static function getCustomFieldID($fieldName, $groupName = NULL, $fullString = FALSE) {
+ $cacheKey = $groupName . '.' . $fieldName;
+ if (!isset(Civi::$statics['CRM_Core_BAO_CustomField'][$cacheKey])) {
$customFieldParams = [
'name' => $fieldName,
'label' => $fieldName,
'options' => ['or' => [["name", "label"]]],
];
- if ($groupTitle) {
- $customFieldParams['custom_group_id.name'] = $groupTitle;
- $customFieldParams['custom_group_id.title'] = $groupTitle;
+ if ($groupName) {
+ $customFieldParams['custom_group_id.name'] = $groupName;
+ $customFieldParams['custom_group_id.title'] = $groupName;
$customFieldParams['options'] = ['or' => [["name", "label"], ["custom_group_id.name", "custom_group_id.title"]]];
}
$field = civicrm_api3('CustomField', 'get', $customFieldParams);
if (empty($field['id'])) {
- Civi::$statics['CRM_Core_BAO_CustomField'][$fieldName]['id'] = NULL;
- Civi::$statics['CRM_Core_BAO_CustomField'][$fieldName]['string'] = NULL;
+ Civi::$statics['CRM_Core_BAO_CustomField'][$cacheKey]['id'] = NULL;
+ Civi::$statics['CRM_Core_BAO_CustomField'][$cacheKey]['string'] = NULL;
}
else {
- Civi::$statics['CRM_Core_BAO_CustomField'][$fieldName]['id'] = $field['id'];
- Civi::$statics['CRM_Core_BAO_CustomField'][$fieldName]['string'] = 'custom_' . $field['id'];
+ Civi::$statics['CRM_Core_BAO_CustomField'][$cacheKey]['id'] = $field['id'];
+ Civi::$statics['CRM_Core_BAO_CustomField'][$cacheKey]['string'] = 'custom_' . $field['id'];
}
}
if ($fullString) {
- return Civi::$statics['CRM_Core_BAO_CustomField'][$fieldName]['string'];
+ return Civi::$statics['CRM_Core_BAO_CustomField'][$cacheKey]['string'];
}
- return Civi::$statics['CRM_Core_BAO_CustomField'][$fieldName]['id'];
+ return Civi::$statics['CRM_Core_BAO_CustomField'][$cacheKey]['id'];
}
/**