CRM-10230 Custom fields text type with limited length not validated
authorsunil <esunil.pawar@gmail.com>
Tue, 31 May 2016 06:27:14 +0000 (11:57 +0530)
committersunil <esunil.pawar@gmail.com>
Tue, 31 May 2016 06:27:14 +0000 (11:57 +0530)
CRM/Core/BAO/CustomField.php

index ec67256b03d887a9dd669e8725798e1c8d5e7c29..8d3297f2b569ac3742774745db947d2442c3f5ee 100644 (file)
@@ -864,6 +864,12 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
           $qf->add('text', $elementName . '_to', ts('To'), $field->attributes);
         }
         else {
+          if ($field->text_length) {
+            $field->attributes .= ' maxlength=' . $field->text_length;
+            if ($field->text_length < 20) {
+              $field->attributes .= ' size=' . $field->text_length;
+            }
+          }
           $element = $qf->add('text', $elementName, $label,
             $field->attributes,
             $useRequired && !$search