django-jsonform icon indicating copy to clipboard operation
django-jsonform copied to clipboard

Decimal values not allowed when entering integer minimum and maximum for 'number' types

Open ErikKoinberg opened this issue 1 year ago • 4 comments

A possible solution could be to add a way to add the step html attribute into the form inputs, perhaps by specifying decimalPlaces for 'number' type fields.

ErikKoinberg avatar Feb 25 '24 21:02 ErikKoinberg

A possible quick-fix that I can think of is to add something like this to the JS: const jsonFormNumberInputs = document.querySelectorAll('input[type="number"][name*="rjf§"]'); jsonFormNumberInputs.forEach(function(input) { input.setAttribute('step', '0.01'); }); This uses the namings of the fields to add a step attribute to these. More specific querying could be used if different number fields need different step values.

ErikKoinberg avatar Feb 25 '24 21:02 ErikKoinberg

I can not reproduce this.

I tried the following schema and I can add a decimal value without problems.

{
  "type": "object",
  "properties": {
    "value": {
      "type": "number",
      "minimum": 1,
      "maximum": 10
    }
  }
}

bhch avatar Feb 28 '24 05:02 bhch

How strange. What browser were you using? After getting rendered into html, I got an input element with min and max values and a number type. When trying to submit a decimal value between the limits it did not work. I am using Firefox.

ErikKoinberg avatar Mar 01 '24 17:03 ErikKoinberg

I'm also using Firefox (119).

Perhaps you could share reproducible code in a sample github repo?

bhch avatar Mar 06 '24 06:03 bhch