Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The default Range field value can be incorrect when a Step value is set #2328

Closed
pryley opened this issue Aug 29, 2020 · 5 comments
Closed

Comments

@pryley
Copy link

pryley commented Aug 29, 2020

Bug Description

The default value of a range field is typically Max - Min / 2 (i.e. (20 - 2) / 2 = 9). However, this does not work well if a Step value is set. For example, suppose the Step value is 2; using the example above, this would make the default value 9 instead of 10.

I figured out that you can add default: 10 to the yaml file to set the default, but I think a better option would be to allow manually setting a default or starting value from the CP.

Extra Detail

image

image

Environment

  • Statamic 3.0.2 Pro
  • Laravel 7.26.1
  • PHP 7.4.8
  • aerni/imagekit 2.2.0
  • aerni/social-links 2.0.1
  • aryehraber/statamic-impersonator 2.0.0
  • aryehraber/statamic-splash 1.0.3
  • doublethreedigital/duplicator 1.0.5
  • kind-work/two-fa 1.0.0
  • rias/statamic-color-swatches 2.0.5
  • spatie/statamic-responsive-images 1.2.3
  • statamic/seo-pro 2.0.10

Install method (choose one):

  • Fresh install from statamic/statamic
@jasonvarga
Copy link
Member

Where did you get that mysterious equation?

@pryley
Copy link
Author

pryley commented Aug 29, 2020

image

This is from the HTML spec, I just simplified it.

@jasonvarga
Copy link
Member

Neat, thanks!

@ReneWeCode
Copy link
Contributor

This really confused me. No other fieldtypes get the defaults set by default.
From a UX perspective the idea is great, but I had to find this issue to actually get the idea.
What really got me, was when I tried to set de default to 0. It's simply not possible from the backend.

If anyone find this closed issue by the same reason as me, and wants to set the default to 0, you can then set the default to '0' in the .md

@jasonvarga
Copy link
Member

Didn't notice your reply @ReneWeCode. Someone just pointed out the same 0 issue. We're on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants