[forms] make it easier to override StringField's mininum size stable
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Fri, 08 Jan 2010 12:14:29 +0100
branchstable
changeset 4215 9fbc39453012
parent 4214 91887e8cf50c
child 4216 6c9e67a89b3a
[forms] make it easier to override StringField's mininum size
web/formfields.py
--- a/web/formfields.py	Fri Jan 08 11:45:37 2010 +0100
+++ b/web/formfields.py	Fri Jan 08 12:14:29 2010 +0100
@@ -1,7 +1,7 @@
 """field classes for form construction
 
 :organization: Logilab
-:copyright: 2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
+:copyright: 2009-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
 """
@@ -218,6 +218,7 @@
 
 class StringField(Field):
     widget = TextArea
+    size = 45
 
     def __init__(self, max_length=None, **kwargs):
         self.max_length = max_length # must be set before super call
@@ -238,7 +239,7 @@
 
     def init_text_input(self, widget):
         if self.max_length:
-            widget.attrs.setdefault('size', min(45, self.max_length))
+            widget.attrs.setdefault('size', min(self.size, self.max_length))
             widget.attrs.setdefault('maxlength', self.max_length)
 
     def init_text_area(self, widget):