web/formfields.py
branchtls-sprint
changeset 1557 d2d5428c7a38
parent 1505 e4c99610e1f7
child 1564 de0548cb0ab8
--- a/web/formfields.py	Thu Apr 30 01:19:50 2009 +0200
+++ b/web/formfields.py	Thu Apr 30 01:20:59 2009 +0200
@@ -180,14 +180,13 @@
     def __init__(self, max_length=None, **kwargs):
         super(StringField, self).__init__(**kwargs)
         self.max_length = max_length
+        if max_length < 513 and isinstance(self.widget, TextArea):
+            self.widget.attrs['cols'], self.widget.attrs['rows'] = 60, 5
 
 
-class TextField(Field):
+class TextField(StringField):
+    """XXX string field not enough?"""
     widget = TextArea
-    def __init__(self, rows=10, cols=80, **kwargs):
-        super(TextField, self).__init__(**kwargs)
-        self.rows = rows
-        self.cols = cols
 
 
 class RichTextField(TextField):
@@ -424,7 +423,7 @@
         if isinstance(cstr, SizeConstraint) and cstr.max is not None:
             if cstr.max > 257:
                 rows_cols_from_constraint(cstr, kwargs)
-                field = TextField(**kwargs)
+                field = TextField(max_length=cstr.max, **kwargs)
             else:
                 field = StringField(max_length=cstr.max, **kwargs)
     return field or TextField(**kwargs)