Problem/Motivation
The 7.x Date module allowed the field to have an optional or required end date. D8 always requires the end date.
Proposed resolution
Make end_value in DateRangeItem optional, add validation constraint via configuration.
Key questions
5 key questions have recurred again and again over the life of this issue:
1. Is the start date optional too? NO
2. What value is stored in the end date property if it is left empty in the widget? NULL
3. Does the optional_end_date setting live in the field config or field storage config? FIELD CONFIG
4. How are optional and non-optional properties distinguished in the widget? STAR ON REQUIRED PROPERTIES BUT ONLY ON FIELD IF ALL REQUIRED
5. How are missing end dates displayed in the formatter? ONLY START DATE IS SHOWN
Remaining tasks
None
Follow-up issues
- #3395096: Allow start date to be optional
- #3395100: Customise display of missing end date.
- #3401464: Date range should be in the date_time category
- #3404199: Improve UX of validation/constraints for daterange field
User interface changes
Field settings form:
Image may be NSFW.
Clik here to view.
Only start date is displayed when end date is missing:
Image may be NSFW.
Clik here to view.
History of discussion
#35 "I think we will have to `->setRequired(FALSE)` in the field definition, and then set required on the element in the widgets, based on the settings. Still need a update hook at the end, though."
# 39 UX discussion
#45 first patch from mpdonadio
#48 "Should the optional_end_date setting be moved to the field config instead of the field storage config?"
#63 should we allow start date optional
#64 'datetime_iso8601' datatype has never been set to optional in core
#76 no impact on json_api
#84 discussion around how we should display missing end date
#94 further discussion around what values to store & display if unknown end date
#139 first patch that added optional start date
#144 proposal about how to handle required indicators for optional field parts
#171 removed optional start date from patch
#193-195 decision to place setting in field not field storage
#209,210 UX review, agree to change optionality to radios
API changes
None
Data model changes
Date range end column is no longer required at database level.