jazzband / django-floppyforms

Full control of form rendering in the templates.
http://django-floppyforms.readthedocs.org/
Other
839 stars 145 forks source link

IntegerField should set min / max attributes on NumberInput widget #54

Closed stucox closed 11 years ago

stucox commented 12 years ago

The floppyforms IntegerField uses a NumberInput widget by default, which should use the values of the IntegerField's min_value and max_value properties (documented here) as default values for its min and max attributes.

E.g.:

how_many = IntegerField(min_value=0, max_value=10)

should, by default, render as:

<input type="number" min="0" max="10" name="how_many">

I think the widget's attr property should still be able to override these, e.g.:

how_many = IntegerField(min_value=0, max_value=10,
    widget=NumberInput(attrs={'min': 5, 'max': 20})
)

=>

<input type="number" min="5" max="20" name="how_many">