CRM-16629 revert default lengths of text-fields
authorTim Mallezie <tim.mallezie@chiro.be>
Tue, 16 Jun 2015 14:52:03 +0000 (16:52 +0200)
committerTim Mallezie <tim.mallezie@chiro.be>
Tue, 16 Jun 2015 14:52:03 +0000 (16:52 +0200)
CRM/Core/CodeGen/Specification.php

index 516a11e326b5e526e1614c04dff6978507ef228a..1d6b98b2e5bfcd18d9ad112415c11b177ad85150 100644 (file)
@@ -667,7 +667,23 @@ class CRM_Core_CodeGen_Specification {
       return $this->value('size', $fieldXML->html);
     }
     // Infer from <length> tag if <size> was not explicitly set or was invalid
-    return $fieldXML->length;
+    // This map is slightly different from CRM_Core_Form_Renderer::$_sizeMapper
+    // Because we usually want fields to render as smaller than their maxlength
+    $sizes = array(
+      2 => 'TWO',
+      4 => 'FOUR',
+      6 => 'SIX',
+      8 => 'EIGHT',
+      16 => 'TWELVE',
+      32 => 'MEDIUM',
+      64 => 'BIG',
+    );
+    foreach ($sizes as $length => $name) {
+      if ($fieldXML->length <= $length) {
+        return "CRM_Utils_Type::$name";
+      }
+    }
+    return 'CRM_Utils_Type::HUGE';
   }
 
 }