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

Required date range not working #2011

Open
knufri opened this issue Aug 6, 2024 · 1 comment
Open

Required date range not working #2011

knufri opened this issue Aug 6, 2024 · 1 comment

Comments

@knufri
Copy link

knufri commented Aug 6, 2024

Describe the bug

If you create a date field and set it as a required field and use it with flatpickr you cannot submit the form because the flatpickr input field has the required attribute but does not get a value but only the hidden field.
Bildschirmfoto 2024-08-06 um 19 40 37

After the daterange is filled and I try to submit the form I get this error:
Bildschirmfoto 2024-08-06 um 19 41 47

Steps to reproduce

  1. Create a date field marked as required
  2. Use flatpickr with mode range
  3. Fill out the date field
  4. Try to submit the form

Form settings

  • Multi-page form: No
  • Submission Method: Ajax
  • Client-side Validation: No
  • Custom Form Templates: No

Craft CMS version

Craft Solo 5.2.10

Plugin version

3.0.0

Multi-site?

No

Additional context

No response

@engram-design
Copy link
Member

This is more of an issue that you can't store a range (multiple dates) for a date field. It only allows for a single date. Server-side validation is going to try and parse a range as a single date, which will fail, stripping the value for the field, after which it's going to detect that the field has no value.

Date ranges aren't currently supported whether they're required on not, sorry. The resolution would be to roll your own Flatpikr instance with a Single-Line Text field so you can store the date as a ranged string.

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

2 participants