Opened 11 years ago

Closed 11 years ago

Last modified 5 months ago

#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)

comment:1 by Claude Paroz, 11 years ago

Resolution: wontfix
Status: newclosed

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.

in reply to:  1 ; comment:2 by bps, 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 ((.

in reply to:  2 comment:3 by Claude Paroz, 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.

comment:4 by Natalia Bidart, 5 months ago

#35600 was a duplicate.

Note: See TracTickets for help on using tickets.
Back to Top