self::addToErrorMsg(ts('field ID'), $errorMessage);
}
// validate null values for required custom fields of type boolean
- if ($customFields[$customFieldID]['is_required'] && (empty($params['custom_'.$customFieldID]) && $params['custom_'.$customFieldID] !== 0) && $customFields[$customFieldID]['data_type'] == 'Boolean') {
+ if ($customFields[$customFieldID]['is_required'] && (empty($params['custom_'.$customFieldID]) && !is_numeric($params['custom_'.$customFieldID])) && $customFields[$customFieldID]['data_type'] == 'Boolean') {
self::addToErrorMsg($customFields[$customFieldID]['label'].'::'.$customFields[$customFieldID]['groupTitle'], $errorMessage);
}
}
elseif ($customFields[$customFieldID]['data_type'] == 'Boolean') {
if (CRM_Utils_String::strtoboolstr($value) === FALSE) {
- self::addToErrorMsg($customFields[$customFieldID]['label'], $errorMessage);
+ self::addToErrorMsg($customFields[$customFieldID]['label'].'::'.$customFields[$customFieldID]['groupTitle'], $errorMessage);
}
}
// need not check for label filed import
self::formatCustomDate($params, $formatted, $dateType, $key);
}
elseif ($customFields[$customFieldID]['data_type'] == 'Boolean') {
- if (empty($val) && !empty($params['id']) && !is_numeric($val) && $this->_onDuplicate == CRM_Import_Parser::DUPLICATE_FILL) { //retain earlier value when Import mode is `Fill`
+ if (empty($val) && !is_numeric($val) && $this->_onDuplicate == CRM_Import_Parser::DUPLICATE_FILL) {
+ //retain earlier value when Import mode is `Fill`
unset($params[$key]);
}
else {
// to check if not update mode and unset the fields with empty value.
if (!$this->_updateWithId && array_key_exists('custom', $formatted)) {
foreach ($formatted['custom'] as $customKey => $customvalue) {
+ if (empty($formatted['custom'][$customKey][- 1]['is_required'])) {
+ $formatted['custom'][$customKey][-1]['is_required'] = $customFields[$customKey]['is_required'];
+ }
$emptyValue = CRM_Utils_Array::value('value', $customvalue[ - 1]);
if (!isset($emptyValue)) {
unset($formatted['custom'][$customKey]);
$valid = CRM_Core_BAO_CustomValue::typecheck(CRM_Utils_Array::value('type', $value),
CRM_Utils_Array::value('value', $value)
);
- if (!$valid) {
+ if (!$valid && $value['is_required']) {
return civicrm_api3_create_error('Invalid value for custom field \'' .
CRM_Utils_Array::value('name', $custom) . '\''
);