Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

Float values in Range slider

admin form

Started by David Huss 5 years ago · 0 replies · 877 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 Ton Haarmans, 5 years ago
13 1140 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 63 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 138 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 114 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 132 7 months ago