if ($unique) {
if (empty($fields['id'])) {
$lowercase_entity = _civicrm_api_get_entity_name_from_camel(_civicrm_api_get_entity_name_from_dao($bao));
- $fields['id'] = $fields[$lowercase_entity . '_id'];
- unset($fields[$lowercase_entity . '_id']);
+ if (isset($fields[$lowercase_entity . '_id'])) {
+ $fields['id'] = $fields[$lowercase_entity . '_id'];
+ unset($fields[$lowercase_entity . '_id']);
+ }
}
return $fields;
}
foreach ($fields as $fieldName => $fieldInfo) {
if (!empty($fieldInfo['FKClassName'])) {
if (!empty($params[$fieldName])) {
- _civicrm_api3_validate_constraint($params[$fieldName], $fieldName, $fieldInfo);
+ foreach ((array) $params[$fieldName] as $fieldValue) {
+ _civicrm_api3_validate_constraint($fieldValue, $fieldName, $fieldInfo);
+ }
}
elseif (!empty($fieldInfo['required'])) {
throw new Exception("DB Constraint Violation - $fieldName should possibly be marked as mandatory for $entity,$action API. If so, please raise a bug report.");