verbb / formie

The most user-friendly forms plugin for Craft CMS.
Other
95 stars 72 forks source link

Required date range not working #2011

Open knufri opened 3 months ago

knufri commented 3 months ago

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

Craft CMS version

Craft Solo 5.2.10

Plugin version

3.0.0

Multi-site?

No

Additional context

No response

engram-design commented 3 months ago

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.