# HG changeset patch # User Aurelien Campeas # Date 1247133974 -7200 # Node ID 22b5ea0679ed33c435159338aba2aea77f64a00e # Parent 5f5259e838cbbf2b46338f453cad95608b30e11b [formfields] set a reasonable minimal minimum length to input/text, also set the max length if applicable (closes #344538) diff -r 5f5259e838cb -r 22b5ea0679ed web/formfields.py --- a/web/formfields.py Thu Jul 09 11:55:47 2009 +0200 +++ b/web/formfields.py Thu Jul 09 12:06:14 2009 +0200 @@ -203,6 +203,11 @@ widget = Select() elif self.max_length and self.max_length < 257: widget = TextInput() + maxlength = self.max_length or 45 + widget.attrs.setdefault('size', min(45, maxlength)) + if self.max_length: + widget.attrs.setdefault('maxlength', self.max_length) + super(StringField, self).init_widget(widget) if isinstance(self.widget, TextArea): self.init_text_area(self.widget)