Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#20674 closed New feature (wontfix)

html5 Input Type: range

Reported by: bps Owned by: nobody
Component: Forms Version: master
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 (3)

comment:1 follow-up: Changed 2 years ago by claudep

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

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.

comment:2 in reply to: ↑ 1 ; follow-up: Changed 2 years ago by bps

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 in reply to: ↑ 2 Changed 2 years ago by claudep

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.

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