CRM-15597 - Fix display of frozen custom contactRef fields
authorColeman Watts <coleman@civicrm.org>
Sat, 15 Nov 2014 02:03:49 +0000 (21:03 -0500)
committerColeman Watts <coleman@civicrm.org>
Sat, 15 Nov 2014 02:03:49 +0000 (21:03 -0500)
CRM/Core/Form/Renderer.php
templates/CRM/Custom/Form/ContactReference.tpl

index d5eaf254c807aee450f71433edf4400db20adc61..7eee0a3a42220dadd7c91f3686d7d51db599ff52 100644 (file)
@@ -244,6 +244,12 @@ class CRM_Core_Form_Renderer extends HTML_QuickForm_Renderer_ArraySmarty {
     $entity = $field->getAttribute('data-api-entity');
     $vals = json_decode($field->getAttribute('data-entity-value'), TRUE);
     $display = array();
+
+    // Custom fields of type contactRef store their data in a slightly different format
+    if ($field->getAttribute('data-crm-custom') && $entity == 'contact') {
+      $vals = array(array('id' => $vals['id'], 'label' => $vals['text']));
+    }
+
     foreach ($vals as $val) {
       // Format contact as link
       if ($entity == 'contact' && CRM_Contact_BAO_Contact_Permission::allow($val['id'], CRM_Core_Permission::VIEW)) {
index 44f7f001a40d37a743e65e99f6e7e5093d601d9d..7c04b5ac864952c29e3801b77bd409a0c2c72159 100644 (file)
@@ -24,6 +24,7 @@
  +--------------------------------------------------------------------+
 *}
 {* Js needed to initialize custom field of type ContactReference *}
+{if empty($form.$element_name.frozen)}
 {literal}
 <script type="text/javascript">
   CRM.$(function($) {
@@ -48,3 +49,4 @@
 });
 </script>
 {/literal}
+{/if}