#20674 closed New feature (wontfix)
html5 Input Type: range
Reported by: | bps | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | html5, range, field types |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hello!
New html5 input types was added (NumberInput, EmailInput, URLInput etc.) - it's beautiful. But what about the RangeInput?
Example:
<input type="range" name="points" min="1" max="10">
It has following attributes:
max - specifies the maximum value allowed min - specifies the minimum value allowed step - specifies the legal number intervals value - Specifies the default value
Change History (4)
follow-up: 2 comment:1 by , 11 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
follow-up: 3 comment:2 by , 11 years ago
Replying to claudep:
I think the idea is that Django provides the most natural widget types for each of its form fields, that's why we added the specialized new input types (IntegerField -> NumberInput, EmailField -> EmailInput, URLField -> URLInput).
Now we don't plan to cover the entire range of new input types as individual widget classes, as it is so easy to create your own for your needs. You can do that by either creating your own Input subclasses, or even by specifying attributes in widget initialization:
count = forms.IntegerField(widget=NumberInput(attrs={'type':'range', 'step': '2'}))See also https://docs.djangoproject.com/en/dev/ref/forms/widgets/#styling-widget-instances
If you'd like to discuss that with a broader audience, feel free to bring that topic on the django-developers mailing list.
But RangeInput need validation on server side (max, min, step), like NumberInput, EmailInput, URLInput. At the moment I must write custom validators for range input ((.
comment:3 by , 11 years ago
Replying to bps:
But RangeInput need validation on server side (max, min, step), like NumberInput, EmailInput, URLInput. At the moment I must write custom validators for range input ((.
For max and min, you should be able to use the current validators available for IntegerField. For any more specialized validation like step
, providing a custom validator at form field level is the way to go. It's not common enough to warrant integration in core, in my opinion.
I think the idea is that Django provides the most natural widget types for each of its form fields, that's why we added the specialized new input types (IntegerField -> NumberInput, EmailField -> EmailInput, URLField -> URLInput).
Now we don't plan to cover the entire range of new input types as individual widget classes, as it is so easy to create your own for your needs. You can do that by either creating your own Input subclasses, or even by specifying attributes in widget initialization:
See also https://docs.djangoproject.com/en/dev/ref/forms/widgets/#styling-widget-instances
If you'd like to discuss that with a broader audience, feel free to bring that topic on the django-developers mailing list.