Opened 3 years ago

Closed 3 years ago

#21752 closed Bug (fixed)

forms.NumberInput - "step" always forced to "any", cannot modify

Reported by: orcein@… Owned by: Claude Paroz
Component: Forms Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'm trying to customize my form widgets, and I have the following code:

rand_range = forms.NumberInput(attrs={'step': 0.01, 'max': 1.0, 'min': 0.0})

However when the field is rendered in HTML, the step is always set to "any". I have also tried putting the number in quotes to no perceivable result. "min" and "max" values are working correctly.

Attachments (1)

21752-1.diff (2.1 KB) - added by Claude Paroz 3 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 3 years ago by Tim Graham

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

Could you write a test for Django's test suite that demonstrates the issue? There are some tests for step in forms_tests/tests/test_fields.py.

comment:2 Changed 3 years ago by Claude Paroz

Owner: changed from nobody to Claude Paroz
Status: newassigned
Triage Stage: UnreviewedAccepted

I can confirm. I'll investigate this issue.

Changed 3 years ago by Claude Paroz

Attachment: 21752-1.diff added

comment:3 Changed 3 years ago by Claude Paroz

Has patch: set

Here's the most straightforward way to fix this issue.

comment:4 Changed 3 years ago by Claude Paroz <claude@…>

Resolution: fixed
Status: assignedclosed

In 18374c1d8c37dd251dae72470b6c532bddf140eb:

Fixed #21752 -- Prevented custom widget step attribute to be overwritten

Thanks orcein at gmail.com for the report.

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