bhch / django-jsonform

A better, user-friendly JSON editing form field for Django admin. Also supports Postgres ArrayField.
https://django-jsonform.rtfd.io
BSD 3-Clause "New" or "Revised" License
307 stars 31 forks source link

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

Open ErikKoinberg opened 4 months ago

ErikKoinberg commented 4 months ago

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 commented 4 months ago

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.

bhch commented 4 months ago

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
    }
  }
}
ErikKoinberg commented 4 months ago

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.

bhch commented 4 months ago

I'm also using Firefox (119).

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