Index: django/forms/widgets.py
===================================================================
--- django/forms/widgets.py (Revision 8287)
+++ django/forms/widgets.py (Arbeitskopie)
@@ -345,7 +345,7 @@
if value is None: value = ''
final_attrs = self.build_attrs(attrs, name=name)
output = [u'')
@@ -361,15 +361,18 @@
# Normalize to strings.
selected_choices = set([force_unicode(v) for v in selected_choices])
output = []
+ output_length = 0
for option_value, option_label in chain(self.choices, choices):
+ output_length += 1
if isinstance(option_label, (list, tuple)):
output.append(u'')
else:
output.append(render_option(option_value, option_label))
- return u'\n'.join(output)
+ return u'\n'.join(output), output_length
class NullBooleanSelect(Select):
"""
@@ -398,9 +401,13 @@
class SelectMultiple(Select):
def render(self, name, value, attrs=None, choices=()):
if value is None: value = []
+ options, options_length = self.render_options(choices, value)
final_attrs = self.build_attrs(attrs, name=name)
+ # default size attribute for cross-browser consistent rendering
+ if 'size' not in final_attrs:
+ # emulate the behaviour of firefox: adjust the size to the number of choices, with an upper boundary
+ final_attrs['size'] = min(10, max(1, options_length))
output = [u'')
Index: tests/modeltests/model_forms/models.py
===================================================================
--- tests/modeltests/model_forms/models.py (Revision 8287)
+++ tests/modeltests/model_forms/models.py (Arbeitskopie)
@@ -342,7 +342,7 @@
-
Categories: | |
---|