From: Coleman Watts Date: Wed, 13 Jul 2022 21:30:02 +0000 (-0400) Subject: Allow custom fields to have custom fields X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f0f4dc8d13a14412c5342ff6d847e610274101f1;p=civicrm-core.git Allow custom fields to have custom fields Theoretically a custom field could have custom fields! Trippy... Fixes dev/core#3731 --- 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; }