#21752 closed Bug (fixed)

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

Reported by: orcein@… Owned by: claudep
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 claudep 20 months ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 20 months ago by timo

  • 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 20 months ago by claudep

  • Owner changed from nobody to claudep
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

I can confirm. I'll investigate this issue.

Changed 20 months ago by claudep

comment:3 Changed 20 months ago by claudep

  • Has patch set

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

comment:4 Changed 20 months ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

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