1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #20630 -- Removed maxlength attribute from NumberInput.

This attribute is only allowed on inputs of type "text", "search", "url",
"tel", "email", or "password".

Thanks to yoyoma for the report and @bmispelon for the review.
This commit is contained in:
Simon Charette
2013-06-19 23:42:23 -04:00
parent 6ef199a08e
commit 04628e2016
3 changed files with 5 additions and 11 deletions

View File

@@ -370,14 +370,8 @@ class DecimalField(IntegerField):
def widget_attrs(self, widget):
attrs = super(DecimalField, self).widget_attrs(widget)
if isinstance(widget, NumberInput):
if self.max_digits is not None:
max_length = self.max_digits + 1 # for the sign
if self.decimal_places is None or self.decimal_places > 0:
max_length += 1 # for the dot
attrs['maxlength'] = max_length
if self.decimal_places:
attrs['step'] = '0.%s1' % ('0' * (self.decimal_places-1))
if isinstance(widget, NumberInput) and self.decimal_places:
attrs['step'] = '0.%s1' % ('0' * (self.decimal_places - 1))
return attrs