Civi::cache('metadata')->clear();
foreach ($customFields as $index => $customField) {
- CRM_Utils_Hook::post(empty($records[$index]['id']) ? 'create' : 'edit', 'CustomField', $customField->id, $customField);
+ $op = empty($records[$index]['id']) ? 'create' : 'edit';
+ // Theoretically a custom field could have custom fields! Trippy...
+ if (!empty($records[$index]['custom']) && is_array($records[$index]['custom'])) {
+ CRM_Core_BAO_CustomValueTable::store($records[$index]['custom'], static::$_tableName, $customField->id, $op);
+ }
+ CRM_Utils_Hook::post($op, 'CustomField', $customField->id, $customField);
}
return $customFields;
}