Add settings to define #date_increment for datetime and datetime_range 'default' widgets

Created on 4 April 2016, over 8 years ago
Updated 23 April 2024, 8 months ago

Problem/Motivation

The 7.x Date module allowed the field to specify which parts of the date to collect (Year, Month, Day, Hour, Minute, and Second):

For parts of the date that are not collected, those are stored as 00. For instance, if one choses to not collect seconds, then the date is stored as 2016-04-03 12:15:00.

Proposed resolution

Add this functionality to the date form widgets.

Remaining tasks

User interface changes

API changes

Data model changes

This shouldn't impact field storage, but would add an option to the field definition config.

โœจ Feature request
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
Datetimeย  โ†’

Last updated 2 days ago

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States jhedstrom Portland, OR

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia junaidpv Kannur, Kerala

    Same as #50 but handling "Undefined variable $element" warning messages additionally.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    There was an ancient issue fork here with no 11.x branch and no MR. I just pushed a ton of modern commits into it, then #50 as a real commit, and opened https://git.drupalcode.org/project/drupal/-/merge_requests/7239.

    Let's see what the bot now thinks. I'll also try some local manual testing...

  • Pipeline finished with Failed
    9 months ago
    #132183
  • Pipeline finished with Failed
    9 months ago
    Total: 179s
    #132190
  • Pipeline finished with Success
    9 months ago
    #132222
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    Had to step away for a while. Pushed some more commits to make phpstan happy. Local testing result is that all seems to work as expected.

    Note to any folks who are having trouble, this is a widget setting, not a field setting. Updating the title to hopefully be more clear.

    However, I notice that the 'Select list' widgets already support this setting, but call it "Time increments". The new setting for the 'Date and time' widgets is now called "Step". We almost certainly want to be consistent here. Any objections to changing the new setting to mimic the existing one?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    Screenshots of both the existing widget settings form for the 'Select list' datetime widget, and the new settings form for the 'Date and time' widget added with this MR. Shows we need to be consistent here, IMHO.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States seanr

    Do we have a working patch for D10, or can a backport be made? I just got a client request that needs this and obviously the D10 diff didn't apply. ๐Ÿ˜‚

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    https://git.drupalcode.org/project/drupal/-/merge_requests/7239.diff works against 10.2.x as of right now. It doesn't apply cleanly directly with git apply, but it works with patch -p1 < 7239.diff. That's what I've been using. ๐Ÿ˜…

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States seanr

    How can I get composer to do that? Here's what I just tried with no luck:

    {
      "patches": {
        "drupal/core": [
          {
            "description": "#2699895: Date increment fix",
            "url": "https://git.drupalcode.org/project/drupal/-/merge_requests/7239.diff",
            "depth": 1
          }
        ],
    ...
    

    Error from composer:

    No available patcher was able to apply patch https://git.drupalcode.org/project/drupal/-/merge_requests/7239.diff to drupal/core

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States seanr

    More detail:

    'git' -C '/var/www/html/web/core' apply --check --verbose -p1 '/mnt/ddev-global-cache/composer/patches/a3bd64da48f2f91a9432010435e27ddba600cadf60f985ff08e5cfc3b25b35c6.patch'
    Checking patch core/lib/Drupal/Core/Render/Element/Date.php...
    error: core/lib/Drupal/Core/Render/Element/Date.php: No such file or directory
    Checking patch core/modules/datetime/config/schema/datetime.schema.yml...
    error: core/modules/datetime/config/schema/datetime.schema.yml: No such file or directory
    Checking patch core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDefaultWidget.php...
    error: core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDefaultWidget.php: No such file or directory
    Checking patch core/modules/datetime_range/config/schema/datetime_range.schema.yml...
    error: core/modules/datetime_range/config/schema/datetime_range.schema.yml: No such file or directory
    Checking patch core/modules/datetime_range/src/Plugin/Field/FieldWidget/DateRangeDefaultWidget.php...
    error: core/modules/datetime_range/src/Plugin/Field/FieldWidget/DateRangeDefaultWidget.php: No such file or directory
    Checking patch core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldWidgetSettingsTest.php...
    error: core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldWidgetSettingsTest.php: No such file or directory
    
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    Off topic from this issue, but you should never point composer at a GitLab MR. Anyone could push broken or malicious code to the MR but the path doesnโ€™t change and composer will happily try to apply the now broken or vulnerable code to your site.

    Download the patch. Store it locally. Tell composer to apply that. Iโ€™ve got a clean checkout for core development. Apply it there. Make a new patch. Put that in your composer.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States seanr

    Hadn't thought of that (still more used to the old-school patches that were static once uploaded). Thank you.

Production build 0.71.5 2024