Merge pull request #3004 from sgladstone/master
[civicrm-core.git] / CRM / Core / Form / Renderer.php
index 0c3c4dbef1f8ce339fed3142c3dec4f70f7f5814..19297c8173500e085981551ae7c1ec89565f69d6 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -122,7 +122,7 @@ class CRM_Core_Form_Renderer extends HTML_QuickForm_Renderer_ArraySmarty {
       if ($element->getAttribute('data-api-entity') && $element->getAttribute('data-entity-value')) {
         $this->renderFrozenEntityRef($el, $element);
       }
-      $el['html'] = '<div class="crm-frozen-field">' . $el['html'] . '</div>';
+      $el['html'] = '<span class="crm-frozen-field">' . $el['html'] . '</span>';
     }
     // Active form elements
     else {
@@ -130,7 +130,7 @@ class CRM_Core_Form_Renderer extends HTML_QuickForm_Renderer_ArraySmarty {
         $this->addOptionsEditLink($el, $element);
       }
 
-      if ($element->getType() == 'group' && $element->getAttribute('unselectable')) {
+      if ($element->getType() == 'group' && $element->getAttribute('allowClear')) {
         $this->appendUnselectButton($el, $element);
       }
     }
@@ -211,7 +211,6 @@ class CRM_Core_Form_Renderer extends HTML_QuickForm_Renderer_ArraySmarty {
     }
     if ($val) {
       $entity = $field->getAttribute('data-api-entity');
-      $select = json_decode($field->getAttribute('data-select-params'), TRUE);
       $api = json_decode($field->getAttribute('data-api-params'), TRUE);
       $params = CRM_Utils_Array::value('params', $api, array());
       // Support serialized values
@@ -224,10 +223,6 @@ class CRM_Core_Form_Renderer extends HTML_QuickForm_Renderer_ArraySmarty {
         $field->removeAttribute('class');
       }
       if (!empty($result['values'])) {
-        // Simplify array for single selects - makes client-side code simpler (but feels somehow wrong)
-        if (empty($select['multiple'])) {
-          $result['values'] = $result['values'][0];
-        }
         $field->setAttribute('data-entity-value', json_encode($result['values']));
       }
     }
@@ -235,22 +230,19 @@ class CRM_Core_Form_Renderer extends HTML_QuickForm_Renderer_ArraySmarty {
 
   /**
    * Render entity references as text.
-   * If user has permission, format as link (or now limited to contacts).
+   * If user has permission, format as link (for now limited to contacts).
    * @param $el array
    * @param $field HTML_QuickForm_element
    */
   function renderFrozenEntityRef(&$el, $field) {
     $entity = $field->getAttribute('data-api-entity');
     $vals = json_decode($field->getAttribute('data-entity-value'), TRUE);
-    if (isset($vals['id'])) {
-      $vals = array($vals);
-    }
     $display = array();
     foreach ($vals as $val) {
       // Format contact as link
       if ($entity == 'contact' && CRM_Contact_BAO_Contact_Permission::allow($val['id'], CRM_Core_Permission::VIEW)) {
         $url = CRM_Utils_System::url("civicrm/contact/view", array('reset' => 1, 'cid' => $val['id']));
-        $val['label'] = '<a href="' . $url . '" title="' . ts('View Contact') . '">' . $val['label'] . '</a>';
+        $val['label'] = '<a class="view-' . $entity . ' no-popup" href="' . $url . '" title="' . ts('View Contact') . '">' . $val['label'] . '</a>';
       }
       $display[] = $val['label'];
     }