cms icon indicating copy to clipboard operation
cms copied to clipboard

[6.x] Fix `default: now` on date fields

Open duncanmcclean opened this issue 4 months ago • 0 comments

This pull request fixes an issue with default: now on Date fields (we use default: now on dated entries).

Currently, the date fieldtype's preProcess method returns the current time in UTC. This works fine when time_enabled: true.

However, when it is false, we need to get midnight in the client's timezone, which we can only do in JavaScript. We can re-use the addDate method for this (it's currently used when you click "Add Date" on an optional date field).

Because setting the field's value will make the page dirty, I've added a line to ensure the publish container's dirty state is cleared on the next tick, avoiding unnecessary dirty state warnings.

Fixes #12585

duncanmcclean avatar Nov 13 '25 17:11 duncanmcclean