Merge pull request #8068 from colemanw/CRM-17832
[civicrm-core.git] / CRM / Core / Form / Renderer.php
index 1339757e57ab3655e16a9c54f373e9210c4cf264..47ee1534c6aa53fa36d63f124c1cec3ebb9649d5 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
+ | Copyright CiviCRM LLC (c) 2004-2016                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
+ * @copyright CiviCRM LLC (c) 2004-2016
  * $Id$
  *
  */
@@ -125,8 +125,13 @@ class CRM_Core_Form_Renderer extends HTML_QuickForm_Renderer_ArraySmarty {
         $date .= ($element->getAttribute('timeformat')) ? " $time" : '';
         $el['html'] = $date . '<input type="hidden" value="' . $element->getValue() . '" name="' . $element->getAttribute('name') . '">';
       }
-
-      $el['html'] = '<span class="crm-frozen-field">' . $el['html'] . '</span>';
+      if ($el['name'] == 'details') {
+        $el['html'] = str_replace('<br />', '', $el['html']);
+        $el['html'] = '<span class="crm-frozen-field">' . html_entity_decode($el['html']) . '</span>';
+      }
+      else {
+        $el['html'] = '<span class="crm-frozen-field">' . $el['html'] . '</span>';
+      }
     }
     // Active form elements
     else {
@@ -192,6 +197,17 @@ class CRM_Core_Form_Renderer extends HTML_QuickForm_Renderer_ArraySmarty {
     elseif (strpos($class, 'crm-form-contact-reference') !== FALSE) {
       self::preprocessContactReference($element);
     }
+    // Hack to support html5 fields (number, url, etc)
+    else {
+      foreach (CRM_Core_Form::$html5Types as $type) {
+        if (strpos($class, "crm-form-$type") !== FALSE) {
+          $element->setAttribute('type', $type);
+          // Also add the "base" class for consistent styling
+          $class .= ' crm-form-text';
+          break;
+        }
+      }
+    }
 
     if ($required) {
       $class .= ' required';
@@ -245,7 +261,7 @@ class CRM_Core_Form_Renderer extends HTML_QuickForm_Renderer_ArraySmarty {
    * @param HTML_QuickForm_element $field
    */
   public function renderFrozenEntityRef(&$el, $field) {
-    $entity = $field->getAttribute('data-api-entity');
+    $entity = strtolower($field->getAttribute('data-api-entity'));
     $vals = json_decode($field->getAttribute('data-entity-value'), TRUE);
     $display = array();