# HG changeset patch # User Adrien Di Mascio # Date 1262949269 -3600 # Node ID 9fbc39453012578013268c1d99d13e71dd3b9904 # Parent 91887e8cf50cb78aeda7d12fe6e94e6dc1c7f0aa [forms] make it easier to override StringField's mininum size diff -r 91887e8cf50c -r 9fbc39453012 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):