set default select size to 1 into the widget
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 28 May 2009 18:46:04 +0200
changeset 1989 8c8dead642f7
parent 1988 b5c5c088bb03
child 1994 56a235af050e
set default select size to 1 into the widget
web/formfields.py
web/formwidgets.py
--- a/web/formfields.py	Thu May 28 18:45:51 2009 +0200
+++ b/web/formfields.py	Thu May 28 18:46:04 2009 +0200
@@ -200,8 +200,6 @@
         super(StringField, self).init_widget(widget)
         if isinstance(self.widget, TextArea):
             self.init_text_area(self.widget)
-        elif isinstance(self.widget, Select):
-            self.widget.attrs.setdefault('size', 1)
 
     def init_text_area(self, widget):
         if self.max_length < 513:
@@ -242,7 +240,6 @@
             else:
                 # else we want a format selector
                 fkwargs['widget'] = Select()
-                fkwargs['widget'].attrs['size'] = 1
                 fcstr = FormatConstraint()
                 fkwargs['choices'] = fcstr.vocabulary(req=req)
                 fkwargs['internationalizable'] = True
--- a/web/formwidgets.py	Thu May 28 18:45:51 2009 +0200
+++ b/web/formwidgets.py	Thu May 28 18:46:04 2009 +0200
@@ -177,8 +177,8 @@
 
     def render(self, form, field):
         name, curvalues, attrs = self._render_attrs(form, field)
-        if not 'size' in attrs and self._multiple:
-            attrs['size'] = '5'
+        if not 'size' in attrs:
+            attrs['size'] = self._multiple and '5' or '1'
         options = []
         optgroup_opened = False
         for label, value in field.vocabulary(form):