Default start and end date functionality inherited from datetime_range does not work.
Default values are not being set because widget trips on lack of time zone.
Needs widget and programmatic tests
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 3018426-default-time-zones-13.patch | 23.29 KB | dpi |
| #13 | interdiff-3018426-default-time-zones-7-13.txt | 759 bytes | dpi |
Comments
Comment #2
dpiThis is WIP
Comment #3
dpiPatch adds time zone field for default values, in addition to default time zone for #3021114: Allow specifying a time zone for default field value.
Tests WIP.
Comment #5
dpiRemoved time override option and tests from basic widget.
Comment #7
dpiComment #9
dpiProviding a way to have field defaults which arnt wiped out before form display (via filterEmptyItems) has proven especially difficult.
In order for defaults to appear, an entire field value must be considered valid, that means a default start date, end date, and time zone must be provided. Rrule is optional.
One workaround for displaying sensible defaults in widgets is to detect if entity is new and field column is NULL, then setting a default there. However we have to be careful that the magic second field value in unlimited cardinality fields isnt also saved because its not considered empty.
Comment #10
dpiI'm considering adding default field value logic to DateRecurItem::appendItem (for when WidgetBase calls it), then in any DR fields making sure unlimited cardinality fields dont get a magic second empty value. Perhaps as a follow up, and alternative to the default time zone feature removed from basic widget in this patch.
Fields items added via AJAX seem to be exempt from filterEmptyItems so even invalid values from appendItem show up.
Comment #11
dpiCreated core issue #3025812: Saving date range fields programmatically without start or end date throws exceptions out from this patch.
Comment #12
dpiComment #13
dpiFix test.
Comment #14
dpiRelevant docs added: https://www.drupal.org/docs/8/modules/recurring-dates-field/date-recur-d...
Comment #16
dpiComment #18
azovsky commentedLooks like this is still not working. I setup default values via UI, but for new nodes with a date_recur field is empty (date-time & timezone).
Comment #19
dureaghin commentedI found a patch https://www.drupal.org/project/date_recur/issues/3111100
Comment #20
dureaghin commented