CRM-9428 - Using custom field data specified with hook_civicrm_customFieldOptions...
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Mon, 2 Nov 2015 10:13:46 +0000 (15:43 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Mon, 2 Nov 2015 10:13:46 +0000 (15:43 +0530)
CRM/Core/BAO/CustomField.php

index 6555a2dcf59d0d243c79f636be269185f6062111..7f509641b319bdb04f1e92f622ed2d536bc96e3a 100644 (file)
@@ -1118,6 +1118,10 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
     $attributes = &$option['attributes'];
     $html_type = $attributes['html_type'];
     $data_type = $attributes['data_type'];
+    // set $id as $fieldID if not passed in the params.
+    if (empty($fieldID)) {
+      $fieldID = $id;
+    }
 
     return self::getDisplayValueCommon($value,
       $option,
@@ -1159,6 +1163,11 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
         $html_type == 'Multi-Select'
       )
     ) {
+      // Keep only the custom option 'key' => 'value' pair
+      // to avoid return of unnecessary data from the hook.
+      if (isset($option['attributes'])) {
+        unset($option['attributes']);
+      }
       CRM_Utils_Hook::customFieldOptions($fieldID, $option);
     }