From f0f4dc8d13a14412c5342ff6d847e610274101f1 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 13 Jul 2022 17:30:02 -0400 Subject: [PATCH] Allow custom fields to have custom fields Theoretically a custom field could have custom fields! Trippy... Fixes dev/core#3731 --- CRM/Core/BAO/CustomField.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index bfde273fb1..e8a3b612c5 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -226,7 +226,12 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { 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; } -- 2.25.1