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

[Panel] Date field min/max settings not validated #1801

Closed
texnixe opened this issue May 26, 2019 · 8 comments
Closed

[Panel] Date field min/max settings not validated #1801

texnixe opened this issue May 26, 2019 · 8 comments
Labels
type: bug 🐛 Is a bug; fixes a bug
Milestone

Comments

@texnixe
Copy link
Member

texnixe commented May 26, 2019

Describe the bug
When setting up a date field with min and max values the settings are not validated.

published:
  type: date
  required: true
  label: Published On
  min: 2019-01-01
  max: 2019-05-01

While the dropdown limits the years to choose from (only if time: true is not set), this is not true for the months and days. Also, you can still pick any date using the date picker. What is more, you cannot only pick a date outside this range, you can also save this date without validation kicking in.

To Reproduce
Steps to reproduce the behavior:

  1. Put the above field into a blueprint
  2. Open/create a page with this blueprint in the Panel
  3. Use the date picker to choose a date outside the given range.
  4. See the page saving without a complaint.

Expected behavior
Dates outside the range should not be pickable nor should they validate.

Screenshots
Bildschirmfoto 2019-05-26 um 13 27 21

Bildschirmfoto 2019-05-26 um 13 11 54

Kirby Version
3.1.4 and feature branch

Desktop (please complete the following information):

  • macOS
  • Safari
@texnixe texnixe changed the title Date field min/max settings not validated [Panel] Date field min/max settings not validated May 26, 2019
@texnixe texnixe added the type: bug 🐛 Is a bug; fixes a bug label May 26, 2019
@GiantCrocodile
Copy link

GiantCrocodile commented May 26, 2019

This is the original thread about the issue I face: https://forum.getkirby.com/t/how-to-use-min-max-for-date-fields/14376

Thanks for reporting this @texnixe!

@texnixe
Copy link
Member Author

texnixe commented May 26, 2019

If I set time: true, the dropdown doesn't even limit the years.

@distantnative distantnative added this to the 3.2.1 milestone May 28, 2019
@bastianallgeier
Copy link
Member

@GiantCrocodile
Copy link

GiantCrocodile commented Jul 4, 2019

I downloaded v3.2.1-rc1 and used the above example and my origonal example. I'm still able to select invalid dates and to save them. Am I doing something wrong @bastianallgeier?

  published:
    type: date
    time: true
        - step: 1
    required: true
    default: now
    label: Published On
    min: 2019-01-01
    max: 2019-05-01

grafik

I tried US and German date format for min/max property.

@texnixe
Copy link
Member Author

texnixe commented Jul 4, 2019

Hm, I can still enter wrong dates, but at least validation does now kick in when I select a wrong date.

@GiantCrocodile
Copy link

I get no validation at all @texnixe. Maybe it is related to the default option. Try this field:

  published:
    type: date
    time: true
        - step: 1
    required: true
    default: now
    label: Published On
    min: 2019-01-01
    max: 2019-05-01

@texnixe
Copy link
Member Author

texnixe commented Jul 4, 2019

Hm, even with that field, it works for me.

Is your page a draft? Drafts are not validated. What happens, if you want to publish it?

The thing is that it probably wouldn't make sense or wouldn't even be possible to limit the days and months shown in a way that would completely make it impossible to select a wrong date - depending on what date ranges you have selected. Let's say you have a date range from 01.01.2015 to 25.06.2017, in that case, you would have to show all days and months. Still, selecting a wrong date like 30.08.2017 would be possible, so validating the date is the only way.

To help the user choosing a correct data, some help text under the field would be useful though.

@GiantCrocodile
Copy link

True, I forgot that validation happens on publishing level, not on draft level, although it happens with required fields earlier (red border around non-filled field).

You are right about showing all days and months in specific situations. But in some cases we could limit it or at least limit the javascript datepicker. I think that would be a cheap but good improvement.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Is a bug; fixes a bug
Projects
None yet
Development

No branches or pull requests

4 participants