Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Float values in Range slider

admin form

Started by David Huss 5 years ago · 0 replies · 1050 views
5 years ago

Does anybody know a good way to let users select floating point values in admin forms?

For non-floating point integer selection I usually used the range slider, and this works quite well. I tried by simply using floating points as min/max/default like this:

YAML
header.margin:
  type: range
  label: "Margin in em"
  default: 0.0
  validate:
    min: 0.0
    max: 4.0

but had no success (the result is just a stepped integer slider with discrete steps of 0, 1, 2, 3 and so on). As a workaround I could just multiply the range by 1000 and then divide it by 1000 in the template, but ideally I'd like to display the real units to the user and not some ×1000 value (in a weird nonstandard unit like mili-em or "mem").

last edited 08/24/21 by David Huss

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Japhy, 2 weeks ago
2 297 6 days ago
Forms & Blueprints · by FrViPofm, 1 month ago
5 346 1 month ago
Forms & Blueprints · by Ton Haarmans, 6 years ago
13 2341 8 months ago
Forms & Blueprints · by Hugo Oliveira, 9 months ago
0 804 9 months ago
Forms & Blueprints · by Flachy Joe, 10 months ago
9 883 10 months ago