Comments

nessthehero created an issue. See original summary.

kevinc_’s picture

Hi,
This is an issue with the DateRecurBasicWidget which doesn't use the settings to add the timezone.

    $timeZone = $items[$delta]->timezone ?? NULL;

Line 77 of the DateRecurBasicWidget.php finds the timezone for pre-existing nodes and sets it to NULL for nodes that are new.

I think this is a bug and am aiming to submit a patch for it today or tomorrow.

kevinc_’s picture

Here is a patch to allow the default timezones set in the field to apply to the DateRecurDefaultWidget.

kevinc_’s picture

Status: Active » Needs review
dpi’s picture

Thanks, I'll take a look in the near future.

socialnicheguru’s picture

I do not even have the Timezone option in default settings.

imclean’s picture

Thanks, the patch in #3 fixes the problem where the default timezone is not being set.

Due to dates not being saved without a timezone, this patch also allows hiding the timezone as per another issue: #3018817: Hiding the timezone empties the dates values

electrokate’s picture

I believe this is also happening with the default settings for the frequency. See screenshots, setting the values does not remove the options to be secondly, hourly, etc.

Also the patch in #3 failed for me when using composer to update.

drenton’s picture

I added a check to always default to the current user's timezone if no default timezone is specified.

dpi’s picture

Title: Content type field defaults do not apply to new nodes. » Allow partially-invalid field value defaults
Version: 8.x-2.0-beta2 » 8.x-2.x-dev
Component: User interface » Field Storage
Category: Bug report » Feature request
Status: Needs review » Needs work

Hi all, so this is a feature/issue with core itself. It lies with the fact that when default values are being computed for a widget, if the item is not fully valid (read: not-empty according to DateRecurItem::isEmpty) then the item is removed.

--------

I have the content type defaults set to start the "Start Date" +1 days from today, and default to the "America/New_York" timezone.

To resolve this, set a default end date. E.g +1 days.

I believe this is also happening with the default settings for the frequency.

If you are setting a default RRULE, then you also need to set a default start, end, timezone.

--------

Direction going forward:

Obviously there is a need to have partial defaults, e.g only default rrule, no start, no end, no timezone. These could be solved on the widget level (see \Drupal\date_recur_modular\DateRecurModularUtilityTrait::getDefaultTimeZone from Modular Widgets, and patches above), or preferably on the field item level as brought up in #3018426-9: Default start and end dates don't work / #3018426-10: Default start and end dates don't work.

Changing direction of issue as a result. Patch is no longer relevant.

dpi’s picture

Created #3040729: Show form validation warning if default values will not end up in widget to cover site builder confusion in the mean time.

balbuf’s picture

I spent a good chunk of time frustrated and trying to figure out why my date wouldn't save (even spinning up separate sites to test the module in isolation) before finding this issue. It is very confusing that the "Start" field is shown as a required component but the "Time zone" field is not, making it incredibly unclear that this is the reason the date isn't saving properly. Further, the partially-entered value shouldn't be erased upon error after saving, but, from what I understand, that is the same issue or related to the main issue here regarding default values?

In any case, thank you for everyone's contributions!

nessthehero’s picture

Just chiming back in on this that my original issue was resolved by @dpi's comment in #10.

I set relative start and end dates to pre-fill the fields and the timezone was set when new events were created.

codebymikey’s picture

I've attached a patch for the widget so that it:

- Inherits the partial default values
- Shows an error message when an invalid time zone is specified (rather than silently invalidate it causing its removal - point three). This fixes the bug where the Recurring dates field entry is deleted when the time zone is set to "- None selected -"

The patch shouldn't introduce any breaking/backwards-incompatible changes.

vidorado’s picture

StatusFileSize
new6.21 KB
new2.09 KB

I've corrected the patch in #14. A !isset() was missing an empty timezone and timezone wasn't being set in the form_state input after setting it in the element.

tclark62’s picture

Not sure if this should be a separate issue, but we would like to provide the field defaults for the Timezone, but also be able to set the default RRule without having to set default dates. Is that in scope for this issue?

dpi’s picture

Version: 8.x-2.x-dev » 3.0.x-dev
Issue summary: View changes

Hi everyone, I've been working on an alternative solution. Which is hopefully more generalized/sustainable.

It fundamentally changes how DateRecurItem::isEmpty works, which is the root cause of this issue.

The changes have only been tested with the Basic widget bundled with this project. This may or may not work well with other widgets yet.

The expected behavior is now you can have any combination of default start or end or time zone instead of requiring all three.

Notably, there is an config upgrade path to adjust how the use current user time zone default setting is stored.

Check out the MR at https://git.drupalcode.org/project/date_recur/-/merge_requests/6

This is just for 3.x branch, I'm debating whether this should be backported to 2.x branch.

dpi’s picture

Version: 3.0.x-dev » 3.2.x-dev
dpi’s picture

Is anyone using the above changeset, and successfully on a live site?

vidorado’s picture

StatusFileSize
new6.09 KB

Re-roll for 3.2

acbramley made their first commit to this issue’s fork.

acbramley’s picture

Status: Needs review » Reviewed & tested by the community

We've been running this in prod for months/years. Let's get it in.

dpi’s picture

Version: 3.2.x-dev » 3.3.x-dev
dpi’s picture

  • dpi committed b2fc6e1a on 3.3.x
    Issue #3030603 by dpi, vidorado, kevinc_, acbramley, drenton,...
dpi’s picture

Status: Reviewed & tested by the community » Fixed

Merged to the unreleased 3.3.x branch!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.