Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Float values in Range slider

admin form

Started by David Huss 5 years ago · 0 replies · 1127 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 Anna, 2 days ago
2 53 16 hours ago
Forms & Blueprints · by Anna, 3 days ago
7 82 16 hours ago
Forms & Blueprints · by Anna, 1 week ago
5 186 6 days ago
Forms & Blueprints · by TomW, 1 month ago
3 379 1 month ago
Forms & Blueprints · by Japhy, 2 months ago
2 595 2 months ago