Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Float values in Range slider

admin form

Started by David Huss 5 years ago · 0 replies · 1005 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 FrViPofm, 5 days ago
5 100 4 days ago
Forms & Blueprints · by Ton Haarmans, 6 years ago
13 2119 7 months ago
Forms & Blueprints · by Hugo Oliveira, 8 months ago
0 604 8 months ago
Forms & Blueprints · by Flachy Joe, 9 months ago
9 694 9 months ago
Forms & Blueprints · by Augustus, 10 months ago
7 741 10 months ago