formie
formie copied to clipboard
Add Date Range field type
What are you trying to do?
A date range field to allow for:
- Improved UI for selecting a date range
- Validation to ensure end date is after start date
What's your proposed solution?
Create a new "Date Range" field type
Additional context
No response
This allready exist.. right..
@wmdhosting Would prefer an option for dedicated fields for each date where each one would have the same options that the current date field does (i.e. dropdown, datepicker, etc). Also, the mode/range approach doesn't allow for time selection.
Same here. I would like to see this added. Even though you can add mode => range
to the Date Picker Options, it doesn't actually work when you submit the form. In Date.php there's a section that normalizes the value.
https://github.com/verbb/formie/blob/0ecab1ac258fe7689e2c4a81c34962f96772d6e4/src/fields/formfields/Date.php#L277C1-L281
flatpickr passes ranges in the format of "2023-06-18 to 2023-06-30". When Formie normalizes this value, it just returns null because it doesn't know how to handle it. This results in a blank value. I'm not even sure how this would be implemented either. The Date class defines the field as yii\db\Schema::TYPE_TIME
or yii\db\Schema::TYPE_DATETIME
(depending on if the field is configured as time only or date/date+time). If it did support multiple values, it would have to be changed over to TYPE_STRING or TYPE_TEXT, which might have huge refactor repercussions.
For now I think all I can do is use two fields (start date and end date), which is too bad. I wanted to be able to use the Available Days option to force ranges to be split into single week chunks.
The same issue occurs when using mode
multiple
it doesn’t show any date in the submission. Will this be fixed in 2.2.0? @engram-design
Frontend:
Submission:
@Maybach91 It probably won't be "fixed" exactly, as we'll implement a new option for the field to use a range. The tricky part is that while you can define Flatpickr to use range
or multiple
from the front-end with JS, we don't know that from the back-end, where we need to normalize the value (as @jmariklecr mentions).
So not so much fixed as addressed properly.
@Maybach91 It probably won't be "fixed" exactly, as we'll implement a new option for the field to use a range. The tricky part is that while you can define Flatpickr to use
range
ormultiple
from the front-end with JS, we don't know that from the back-end, where we need to normalize the value (as @jmariklecr mentions).So not so much fixed as addressed properly.
Thanks! So there is also no workaround for this to make this work? @engram-design