Skip to content

Commit

Permalink
Merge pull request #23995 from colemanw/custom_custom
Browse files Browse the repository at this point in the history
Allow custom fields to have custom fields
  • Loading branch information
eileenmcnaughton authored Jul 16, 2022
2 parents c31f238 + f0f4dc8 commit 2e5ae20
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CRM/Core/BAO/CustomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,12 @@ public static function writeRecords(array $records): array {
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;
}
Expand Down

0 comments on commit 2e5ae20

Please sign in to comment.