Problem/Motivation

Backend date format is different to front end date format (which depends on user's locale) it is not possible to display sample date in the correct format on error messages or in field description on generic form elements.

In Drupal 7 there's no sample date in error messages/description either.

Proposed resolution

  • Remove sample date from error message.
  • Remove title attribute
  • Deprecate DateTime::formatExample

User interface changes

Before:
Title before
Error before

After:
Title after
Error after

(NOTE title attribute has been removed).

Original summary

The Authoring information tab let's people edit the author, date and time a node was originally created.

The date field has placeholder input expecting DD-MM-YYYY

But!

The tooltip says "Date (e.g. 2017-02-11)"
The description says Format: "2017-02-11 01:31:30"

This is inconsistent and confusing. We can't change the datetime format for authored on field because the values going into and coming out of are RFC 3339 / ISO 8601 ( See: https://www.w3.org/TR/html-markup/input.date.html )

Current browsers also seem to be implementing HTML5 date fields in their own special ways. According to Ian Devlin on HTML5Doctor

"The implementation of this datepicker is up to the browser vendor, as the HTML5 specification does not tell vendors how to implement the input’s UI."

"As a user, I expect the help text to guide me to provide the correct date format, so that I can get it right the first time, without guessing."

Can we find a way to make this consistent? We already seem to be automatically inserting today's date here.

CommentFileSizeAuthor
#145 Screenshot 2023-12-19 at 08.37.29.png346 KBjonathan1055
#138 2791693-datetime-issue-fix.patch7.86 KBkavbiswa
#137 2791693-95-137.patch7.19 KBHitchShock
#125 interdiff-2791693-124-125.txt1014 bytesacbramley
#125 2791693-125.patch8.34 KBacbramley
#124 interdiff-2791693-112-124.txt2.36 KBacbramley
#124 2791693-124.patch8.37 KBacbramley
#116 title-after-2.png11.92 KBacbramley
#116 error-after-2.png13.37 KBacbramley
#112 interdiff_107_112.txt1.23 KBnginex
#112 2791693-112.patch8.85 KBnginex
#107 interdiff_99_107.txt1002 bytesnginex
#107 2791693-d11-107.patch8.57 KBnginex
#107 2791693-d11-107-TEST-ONLY-FAIL.patch1.24 KBnginex
#105 interdiff_102_105.txt1002 bytesnginex
#105 2791693-d10-105.patch8.88 KBnginex
#105 2791693-d10-105-TEST-ONLY-FAIL.patch1.24 KBnginex
#102 2791693-d10-102.patch8.71 KBnginex
#102 2791693-d10-102-TEST-ONLY-FAIL.patch1.07 KBnginex
#99 interdiff_98_99.txt701 bytesnginex
#99 2791693-d11-99.patch8.4 KBnginex
#98 2791693-d11-98.patch8.4 KBnginex
#97 interdiff_96_97.txt985 bytesnginex
#97 2791693-d10-97.patch8.71 KBnginex
#96 interdiff_93_96.txt2.43 KBnginex
#96 2791693-96.patch8.75 KBnginex
#93 2791693-93.patch7.64 KBAjeet Tiwari
#92 2791693.92.patch7.27 KBAjeet Tiwari
#91 2791693-91.patch7.27 KBNadim Hossain
#85 interdiff-2791693-80-85.txt742 bytesacbramley
#85 2791693-85.patch7.27 KBacbramley
#85 error-after-authored-on.png14.42 KBacbramley
#80 interdiff-2791693-78-80.txt437 bytesacbramley
#80 2791693-80.patch7.34 KBacbramley
#80 error-after.png12.51 KBacbramley
#80 title-after.png13.65 KBacbramley
#80 error-before.png15.06 KBacbramley
#80 title-before.png16.27 KBacbramley
#79 2791693-drupal-10.png235.59 KBnayana_mvr
#78 interdiff-2791693-63-78.txt1009 bytesacbramley
#78 2791693-78.patch6.84 KBacbramley
#63 2791693-63.interdiff-58-63.txt1.36 KBjonathan1055
#63 2791693-63.remove-sample-date.patch6.58 KBjonathan1055
#58 interdiff_2791693_57-58.txt839 bytesankithashetty
#58 2791693-58.patch5.89 KBankithashetty
#57 interdiff-55-56.txt743 bytesJelle_S
#57 2791693-56.patch5.89 KBJelle_S
#56 2791693-55.patch5.44 KBacbramley
#42 2791693-40-1.patch1.37 KBguaneagler
#41 2791693-40.patch1.37 KBguaneagler
#40 change-time-format-H-i-s-A.patch684 bytesguaneagler
#38 2791693-38.patch5.81 KBjibran
#38 interdiff-1b956d.txt1.29 KBjibran
#35 2791693-33.patch3.12 KBjan kellermann
#33 12659982-33.patch3.21 KBjan kellermann
#29 2791693-datetime-input-ui-29.patch5.53 KBdpi
#29 interdiff-2791693-datetime-input-ui-29.txt1.47 KBdpi
#24 authored_on_invalid_error.png26.87 KBoknate
#23 2791693-23.patch4.39 KBoknate
#21 2791693-21.patch3.09 KBFeyP
#16 remove-erroneous-description-2791693-16.patch1.5 KBoknate
#14 remove-erroneous-description-2791693-14.patch2.08 KBoknate
#11 2791693-browsercomparison.png112.64 KBkattekrab
#4 after-change-code.png12.05 KBamit.drupal
#4 before-change-code.png11.35 KBamit.drupal
#4 wrong-date-time-format-2791693-4.patch2.23 KBamit.drupal
#2 Screen Shot 2016-08-31 at 11.28.23 AM.png30.23 KBjhedstrom

Issue fork drupal-2791693

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

matulis created an issue. See original summary.

jhedstrom’s picture

If I'm understanding, this issue is about the discrepancy between the html5 input, and the old description of the accepted format?

That does indeed look like a documentation/ux issue.

matulis’s picture

it's not just about discrepancy, but inability to change datetime format for authored on field.

amit.drupal’s picture

Status: Active » Needs review
FileSize
2.23 KB
11.35 KB
12.05 KB

Help text is wrong on "Authored on".
submit patch change in help text

mpdonadio’s picture

Version: 8.1.8 » 8.2.x-dev
Status: Needs review » Needs work
  1. +++ b/core/lib/Drupal/Core/Datetime/Plugin/Field/FieldWidget/TimestampDatetimeWidget.php
    @@ -35,7 +35,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
    -    $element['value']['#description'] = $this->t('Format: %format. Leave blank to use the time of form submission.', array('%format' => Datetime::formatExample($date_format . ' ' . $time_format)));
    +    $element['value']['#description'] = $this->t('Format: %format. Leave blank to use the date and time of form submission.', array('%format' => Datetime::formatExample($date_format . ' ' . $time_format)));
     
    
    +++ b/core/modules/content_translation/src/ContentTranslationHandler.php
    @@ -453,7 +453,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En
    -        '#description' => t('Format: %time. The date format is YYYY-MM-DD and %timezone is the time zone offset from UTC. Leave blank to use the time of form submission.', array('%time' => format_date(REQUEST_TIME, 'custom', 'Y-m-d H:i:s O'), '%timezone' => format_date(REQUEST_TIME, 'custom', 'O'))),
    +        '#description' => t('Format: %time. The date format is YYYY-MM-DD and %timezone is the time zone offset from UTC. Leave blank to use the date and time of form submission.', array('%time' => format_date(REQUEST_TIME, 'custom', 'Y-m-d H:i:s O'), '%timezone' => format_date(REQUEST_TIME, 'custom', 'O'))),
    

    These just change some language, not the format sample.

There are a few problems here the we need to balance.

1. Per https://www.w3.org/TR/html-markup/input.date.html, the values going into and coming out of <input type="date"> are RFC 3339 / ISO 8601.

2. When you use a <input type="date">, it is up to the browser to support it or not and how to style the inputs (not sure about definitive reference here, but http://stackoverflow.com/questions/7372038/is-there-any-way-to-change-in... is the closest that I know of).

3. Some browsers don't support these inputs, and treat them as textfields. We have a polyfill for date, and hopefully a polyfill for time will land soon. Both of those rely on JS. Non-JS will have to use the format we define.

4. Drupal on the PHP side doesn't know what a browser supports nor how a user's machine is configured (it, user settings may not follow the Drupal locale settings).

We can't do anything to influence the browser side (eg, Chrome). We may or may not have a localization problem with the polyfill(s) (haven't looked into this much).

I think my suggestion here is to hide the help text when on a supported browser (we have Modernizr in core, but don't add the body classes for a CSS-only solution) or when using the polyfills.

Other thoughts?

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

kattekrab’s picture

Issue summary: View changes
kattekrab’s picture

Issue summary: View changes
kattekrab’s picture

Title: Wrong "Authored on" date & time format » Make the Date Time input format and descriptive text consistent.
kattekrab’s picture

Issue summary: View changes
kattekrab’s picture

FileSize
112.64 KB

On further testing with other browsers - looks like only chrome of the one's I've tested changes the placeholder input format.

Odd.

mpdonadio’s picture

#11 Chrome and Opera are using the native HTML5 date element. Safari and Firefox are using the polyfill (the jQuery UI datepicker). With the polyfill, the entry is essentially a text input and the UI is a "helper" for filling it out.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

oknate’s picture

Here is a patch that just removes the troublesome text. I also feel the "Leave blank to use the time of form submission." doesn't make sense, since it's populated when first hitting the node/add/ page and it doesn't update upon submission. Also it looks like the text differs in the content_translation module.

mpdonadio’s picture

Thanks for working on an old issue.

  1. +++ b/core/lib/Drupal/Core/Datetime/Plugin/Field/FieldWidget/TimestampDatetimeWidget.php
    @@ -35,7 +35,6 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
    -    $element['value']['#description'] = $this->t('Format: %format. Leave blank to use the time of form submission.', ['%format' => Datetime::formatExample($date_format . ' ' . $time_format)]);
    

    Even if the text is bad, we need something there. We can't just remove the form element description all together.

  2. +++ b/core/modules/content_translation/src/ContentTranslationHandler.php
    @@ -463,15 +463,6 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En
    -      $date = $new_translation ? REQUEST_TIME : $metadata->getCreatedTime();
    -      $form['content_translation']['created'] = [
    -        '#type' => 'textfield',
    -        '#title' => t('Authored on'),
    -        '#maxlength' => 25,
    -        '#description' => t('Format: %time. The date format is YYYY-MM-DD and %timezone is the time zone offset from UTC. Leave blank to use the time of form submission.', ['%time' => format_date(REQUEST_TIME, 'custom', 'Y-m-d H:i:s O'), '%timezone' => format_date(REQUEST_TIME, 'custom', 'O')]),
    -        '#default_value' => $new_translation || !$date ? '' : format_date($date, 'custom', 'Y-m-d H:i:s O'),
    -      ];
    -
           if (isset($language_widget)) {
    

    Same note here about the #description, but we also can't remove the form element all together.

oknate’s picture

In this patch, if the parent entity is new, it will leave the field blank, and then indeed it will pick up the date of submission from ::massageFormValues(). This makes the description text more accurate. I have removed the formatting suggestion, since it's obvious from the form element.

Also, I just leave the content_translation module alone. It's using a textfield with a date formatted "Y-m-d H:i:s O" instead of a timestamp, so for now, I'll just leave that form alone.

oknate’s picture

Status: Needs work » Needs review

The last submitted patch, 14: remove-erroneous-description-2791693-14.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

jhedstrom’s picture

+++ b/core/lib/Drupal/Core/Datetime/Plugin/Field/FieldWidget/TimestampDatetimeWidget.php
@@ -29,13 +29,15 @@ class TimestampDatetimeWidget extends WidgetBase {
-    $element['value']['#description'] = $this->t('Format: %format. Leave blank to use the time of form submission.', ['%format' => Datetime::formatExample($date_format . ' ' . $time_format)]);
+    $element['value']['#description'] = $this->t('Leave blank to use the time of form submission.');

I don't think we can remove the format for the reasons expressed in #5. Rather something as suggested there will probably make more sense here:

I think my suggestion here is to hide the help text when on a supported browser (we have Modernizr in core, but don't add the body classes for a CSS-only solution) or when using the polyfills.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

FeyP’s picture

Attached is a quick patch against 8.5.x based on the suggestion by mpdonadio in #5.

oknate’s picture

Status: Needs review » Needs work
oknate’s picture

I believe a javascript only approach should remove the formatting info from the description, but leave the "Leave blank to use the time of form submission."

Also, it would need to address the error message when someone manages to submit invalid data, and remove the formatting info from the error messages as well.

authored on error message has formatting

Here's an update to the non-javascript solution, that updates the error message to remove the formatting info, as well as the content translation description.

I think an additional thing that needs to be looked at is that the content translation "Authored On" element should copy as much as possible from the actual element, as it's current set to to a textfield and the default value is generated differently that the "Authored On" field on untranslated nodes.

oknate’s picture

FeyP’s picture

I believe a javascript only approach should remove the formatting info from the description, but leave the "Leave blank to use the time of form submission."

I would have implemented that, but you said in comment #14, that you thought it didn't make sense.

Also, it would need to address the error message when someone manages to submit invalid data, and remove the formatting info from the error messages as well.

Yes, that's true, I didn't think of that. Thanks for pointing that out.

I was under the impression that it we came to the conclusion previously, that we can't just remove the formatting from the description in code and a JS-approach was needed. Since you continue to work in that direction, I wont update my patch for now. If we agree, that a JS-approach is what we want here, I can update my patch to address your comments. Just let me know.

mpp’s picture

Note that the current patch in #23 doesn't take the tooltip into account Date (YYYY/mm/dd).

mpp’s picture

After some consideration a JavaScript approach seems the only valid path forward here:

1. The Drupal backend has it's own format to validate.
2. The Drupal backend is agnostic to the frontend locale or browser settings (e.g. HTML5 support or not) which may have its own format.
3. The backend validation WITH the backend format is needed for a good UX for users that do not have JavaScript or HTML5 support. A message "The date is invalid" is not an option for these users.

To conclude, we must keep the backend message with the expected backend format.
As a consequence, it is up to the frontend to decide if it shows a custom widget (Jquery or HTML5 element) and to do the proper client side validation.

mpp’s picture

Adding a jQuery Timepicker for the Time element of the datetime field would also be a UX improvement for the datetime field when an HTML5 fallback is used.

dpi’s picture

Version: 8.5.x-dev » 8.6.x-dev
Status: Needs work » Needs review
FileSize
1.47 KB
5.53 KB

Improving on #23 by removing formats in tooltips for date and time fields in DateTime element.

Additionally, no more usages of the formatExample helper in core so added deprecation notice.

jibran’s picture

Title: Make the Date Time input format and descriptive text consistent. » Make the DateTime input format and descriptive text consistent
Issue tags: +Needs usability review

As per https://caniuse.com/#feat=input-datetime, it seems like all browsers now support datetime input field but we need an usability review here first.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

notmike’s picture

jibran's comment in #30 is incorrect. When Safari 12, the default browser in all currently shipping macOS devices, does not support the time input field, you cannot say that "all browsers" support the date and time input types. Even though Safari 12's usage is lower than IE11's (another problematic browser that does not support these input types), it cannot be discounted.

jan kellermann’s picture

This new patch base on patch #21 (JS-only Patch) for Drupal 8.6.x.

Status: Needs review » Needs work

The last submitted patch, 33: 12659982-33.patch, failed testing. View results

jan kellermann’s picture

FileSize
3.12 KB

Use correct filename for patchfile from comment #33 (Drupal 8.6.7).

mpdonadio’s picture

+++ b/core/misc/date.es6.js
@@ -19,15 +19,25 @@
+          if (description_id) {
+            $context.find('#' + description_id).hide();
+          }

Hmmm. I wonder if this will have screenreader problems? IOW, do most current ones honor `display: none` and not read them?

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dalin’s picture

Issue summary: View changes
Issue tags: +Needs accessibility review

If I follow this correctly, this needs both the JS patch and PHP patch combined into a single patch file. Or if I'm wrong, please update the issue summary.

I think the JS patch could also use more code comments, specifically about why things are being hidden/shown.

guaneagler’s picture

Title: Make the DateTime input format and descriptive text consistent » Just simple change the time tip message with AM/PM
Version: 8.8.x-dev » 8.6.x-dev
Assigned: Unassigned » guaneagler
Category: Bug report » Feature request
Issue tags: -datetime form element, -date format, -authored on, -Needs usability review, -Needs accessibility review
Related issues: -#1838234: Add jQuery Timepicker for the Time element of the datetime field
FileSize
684 bytes

I just change the time tip message with AM/PM, I know this is not good, but matching multiple browsers is out of my knowledge.

Wrong patch

guaneagler’s picture

FileSize
1.37 KB
guaneagler’s picture

FileSize
1.37 KB
jonathan1055’s picture

Title: Just simple change the time tip message with AM/PM » Make the DateTime input format and descriptive text consistent
Version: 8.6.x-dev » 8.8.x-dev
Assigned: guaneagler » Unassigned
Category: Feature request » Bug report
Issue tags: +datetime form element, +date format, +authored on, +Needs usability review, +Needs accessibility review
Related issues: +#1838234: Add jQuery Timepicker for the Time element of the datetime field

Hi guaneagler,
Thanks for your interest but I think you have mis-understood the use of this issue queue. You can't just change the title, regress the core version, remove the associated issues & tags and upload a completely different patch. You are welcome to start a new issue with your hard-coded format change but this is not what the original issue is addressing.

Hence I have restored the previous title, links and tags.

Jonathan

Wim Leers’s picture

@mpdonadio indicated at #3072906-57: Deprecate and remove jQuery UI datepicker that this issue may be obsolete if #3072906: Deprecate and remove jQuery UI datepicker lands in its current form. I just wanted to make people who participated in this issue aware of that other issue 😊

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

idebr’s picture

#44 The jQuery UI datepicker was applied for browsers that do not have a native datepicker. This issue is about the native datepicker, so #3072906: Deprecate and remove jQuery UI datepicker did not affect this.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

kim.pepper’s picture

Issue tags: +#pnx-sprint

quietone’s picture

quietone’s picture

kattekrab’s picture

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

acbramley’s picture

FileSize
5.44 KB

Re-roll of #38, applies to 9.3.x and 9.4.x cleanly

Jelle_S’s picture

Status: Needs work » Needs review
FileSize
5.89 KB
743 bytes

Last patch forgot to remove one usage of createFormatExample, causing fatal errors on node edit. This patch fixes it.

ankithashetty’s picture

Updated the @deprecated tag in the above patch, thanks!

joachim’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

The issue summary doesn't match the recent patches.

jannakha’s picture

Title: Make the DateTime input format and descriptive text consistent » Remove sample date from date field error message and description
Issue summary: View changes
Status: Needs work » Needs review
jannakha’s picture

Issue summary: View changes
jannakha’s picture

Status: Needs review » Reviewed & tested by the community

#58 works fine

jonathan1055’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
6.58 KB
1.36 KB

Hi @jannakha, thanks for the feedback. However the tests on #58 did not complete because of two coding standards, so we cant set this to RTBC until at minimum we get green test passes.

New patch #63 for review. I added the @see link to this issue, but ultimately it should point to the Change Record if/when that is created.

jannakha’s picture

Status: Needs review » Reviewed & tested by the community

Hi @jonathan1055

thanks for the fix! all good!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 63: 2791693-63.remove-sample-date.patch, failed testing. View results

jonathan1055’s picture

All tests passed on 4 April, but on 6 April we get a failure in modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.
They passed on 4 April

14  Media.Drupal\Tests\media\FunctionalJavascript\CKEditorIntegrationTest
✓  - testOnlyDrupalMediaTagProcessed
✓  - testErrorMessages
✓  - testPreviewUsesDefaultThemeAndIsClientCacheable
✓  - testEditableCaption
✓  - testDialogAccess
✓  - testAlt
✓  - testTranslationAlt
✓  - testLinkability with data set "linkability when `drupalimage` is enabled"
✓  - testLinkability with data set "linkability when `drupalimage` is disabled"
✓  - testEmbedPreviewAccess with data set "media_embed filter enabled"
✓  - testEmbedPreviewAccess with data set "media_embed filter disabled"
✓  - testEmbedPreviewAccess with data set "media_embed filter enabled, user not allowed to use text format"
✓  - testAlignment
✓  - testViewMode

This is not a file that we have altered in this patch. Has anything changed in core to affect this?

jannakha’s picture

jonathan1055’s picture

Status: Needs work » Needs review

Thanks @jannakha for finding #3273626: Resolve issue with tests for Drupal Media JavaScript causing database locks on SQLite.
Setting back to Needs Review. I can see we have another test run which passed.

jannakha’s picture

Status: Needs review » Reviewed & tested by the community
colan’s picture

It's not clear if this issue helps with setting the date format on the form as per #2936268: Date picker only works with US date and time formats. Can someone unpack that? Looks like Needs issue summary update is already on so not adding it.

jannakha’s picture

@colan this is not a date format issue, it's just message issue. Date format is more of an issue of browsers and browser-native implementation of date-time field.

jonathan1055’s picture

The last two test runs have ended with "build successful" which is actually an error, because not all the tests passed. It seems that some javascript tests failed:

TEST FAILURE: 2 errors during execution; 17 assertions failed, 1348 passed (6m 9s)
✖ Tests/toolbarTest
 – Change tab (5.661s)
   Timed out while waiting for element <#toolbar-item-user-tray> to be present for 5000 milliseconds. - expected "found" but got: "not found" (5166ms)

Maybe this is an unrelated test problem?

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

catch’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/lib/Drupal/Core/Datetime/Element/Datetime.php
@@ -390,6 +387,11 @@ public static function validateDatetime(&$element, FormStateInterface $form_stat
+   *
+   * @deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. HTML date
+   *   input format should not be exposed to users, as browser widgets expose
+   *   input differently, varying by vendor, locale, device type, etc.
+   * @see https://www.drupal.org/project/drupal/issues/2791693
    */
   public static function formatExample($format) {
     if (!static::$dateExample) {

This should also have a @trigger_error(). Don't think we need a deprecation test since it's going to be a straight removal with no bc layer.

Since 9.4.0 is already released, this either needs to be deprecated in 9.5 (which we're generally trying to avoid) or in 10.1. I think given this is a bugfix and it's unlikely that contrib code is calling the method, in 9.5 for removal in 11.x might be best?

The issue is still tagged for usability review, has this happened?

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

jaime@gingerrobot.com’s picture

Issue tags: +widget, +field labels

Hi, on Drupal 9.4.8 the Description is now gone and you can use the help text if you want to customise it. There is a ticket to review date related elements for UX best practices. https://www.drupal.org/project/drupal/issues/2897397 For now there are no labels so this issue is fixed in that respect.

All that remains is making sure we haven't missed anything

jaime@gingerrobot.com’s picture

Issue tags: +Usability
acbramley’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs issue summary update
FileSize
6.84 KB
1009 bytes

Actioned #74 and rerolled against 10.1.x. The issue summary looks good to me as well.

nayana_mvr’s picture

FileSize
235.59 KB

As mentioned in #76, the description mentioned in the ticket's original problem statement has been removed from Drupal version 9.4.8 and above. So need confirmation whether we really need a re-roll here for Drupal 10 version.

Author info

acbramley’s picture

Title: Remove sample date from date field error message and description » Remove sample date from date field error message and title attribute
Issue summary: View changes
FileSize
16.27 KB
15.06 KB
13.65 KB
12.51 KB
7.34 KB
437 bytes

Re #76 and #79 - while the description for the created date has indeed been changed, this ticket is still removing it from other areas - the input's title and error message.

Updated patch with stan baseline fix.

Screenshots:

Before:
Title before
Error before

After:
Title after
Error after

xmacinfo’s picture

@acbramley: I am a bit confused. Does this issue require more work or is it RTBC?

acbramley’s picture

@xmacinfo no, it needs reviewing. It was set to Needs Work in #74 based on the deprecation error. That has been fixed. However, it's also tagged for usability and accessibility review, however I'm not 100% sure if that is required given it's a fairly straight forward change.

xmacinfo’s picture

@acbramley: Thanks for the clarification. Let’s see if we can have usability and accessibility reviews.

AaronMcHale’s picture

Status: Needs review » Needs work
Issue tags: -Needs usability review +Needs followup

Usability review

We reviewed this issue at #3347230: Drupal Usability Meeting 2023-03-17.

That issue will have a link to the recording, for the record the attendees were: myself, @rkoller, @simohell, @shaal and @blackbamboo.

After discussing various options, the group made the following recommendations:

  1. We recommend [field_name] value is incorrect. Enter a valid date and time. for the error message text. For example: "Authored on value is incorrect. Enter a valid date and time".
  2. We also recommend completely removing the title attributes.
  3. In a follow-up issue, we should explore making the validation specific to the individual date or time elements, right now if the error is triggered by the time element, both the date and time elements are highlighted in red. This is not ideal, and we should find a way to highlight the specific element that is causing the error.
  4. We used the "Authored on" Node field to test with, and we noted that the description of that filed could be improved, it simply says "The time that the node was created.", we felt this could be improved by saying "date and time", we also try to avoid the term "node" in the user interface and instead prefer "content". Obviously that is out of scope for this issue, but as with point three it would be useful if a follow-up issue could be filed for that.

Adding the needs followup tag for points 3 and 4.

acbramley’s picture

Thanks @AaronMcHale!

Re 1. - This actually already is the error message (for the Authored On field at least). For other date time fields added to the content type there is no #title attribute on the $element since that comes from the fieldset itself. There is no other way I can see to get the title for those fields, this should be investigated in a follow up imo as it could have large flow on affects for getting that info in there.

The error messages in #80 were when using one of those custom fields (i.e a Date time field added to the Article content type). When testing the Authored on field, it shows correctly:

Error after Authored on

The problem with the title is already a bug in the current error message as well. Since this issue is just about removing the format I think that should be moved to a follow up.

I've removed the title attributes per #84.2.

So looks like we need 3 follow ups?

1. Improve Datetime validation to be specific to Date or Time input
2. Improve Authored On description (fwiw this is manageable using base field overrides although most people wouldn't be interacting with that system.
3. Add field title to Datetime validation error for configurable datetime fields.

acbramley’s picture

Status: Needs work » Needs review

Back to NR

AaronMcHale’s picture

@acbramley Thanks for the reply.

The text that is being proposed is [field_name] value is incorrect. Enter a valid date and time., which is different from what is in the patch in this issue. Note that we have specifically removed the word "invalid".

We probably then should have a follow-up issue to, as you say, remove the title attribute on the fieldset.

acbramley’s picture

So it would be Authored on value is incorrect. Enter a valid date and time? Honestly that reads much worse than what's there currently to me.

To be clear - it's not a title attribute on the fieldset. When a non-base date field is rendered on the form it is wrapped in a fieldset. That fieldset contains the field's label in its legend, it is not a label on the element passed in (i.e not in $element['#title']. Therefore it is not possible to include that label in the error message (that I can see)

smustgrave’s picture

Status: Needs review » Needs work

Not 100% sure what needs accessibility review. If general direction can be pointed out I'm not the worst 508 tester.
Moving to NW for all the follow up tickets being discussed.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Nadim Hossain’s picture

FileSize
7.27 KB

Because of the recent changes in 10.1.x, the patch in #85 does not get applied. So just re-rolling it to be compatible with 10.1.x

Ajeet Tiwari’s picture

Status: Needs work » Needs review
FileSize
7.27 KB

please review.

Ajeet Tiwari’s picture

please review.fixed CCF.

Status: Needs review » Needs work

The last submitted patch, 93: 2791693-93.patch, failed testing. View results

acbramley’s picture

+++ b/core/lib/Drupal/Core/Datetime/Element/Datetime.php
@@ -374,7 +369,7 @@ public static function validateDatetime(&$element, FormStateInterface $form_stat
+          $form_state->setError($element, t('The %field date is invalid. Please enter a date in the valid format.', ['%field' => $title]));

Why has this changed from "in the correct format" to "in the valid format"? Please also post interdiffs with your changes and reasoning behind them.

nginex’s picture

I've fixed an issue in tests. Here is a patch to review.

nginex’s picture

Fixed small issue in the tests after deeper check

nginex’s picture

D11 patch where Datetime::formatExample() was completely removed

nginex’s picture

"Please" is a forbidden word, so here is a new patch for D11

The last submitted patch, 97: 2791693-d10-97.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 99: 2791693-d11-99.patch, failed testing. View results

nginex’s picture

Ok, need to upload test only patch + a full patch

The last submitted patch, 102: 2791693-d10-102-TEST-ONLY-FAIL.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 102: 2791693-d10-102.patch, failed testing. View results

nginex’s picture

Ah, there was issue in the test, I did some cleanup, should be good now

The last submitted patch, 105: 2791693-d10-105-TEST-ONLY-FAIL.patch, failed testing. View results

nginex’s picture

The last submitted patch, 107: 2791693-d11-107-TEST-ONLY-FAIL.patch, failed testing. View results

smustgrave’s picture

Status: Needs review » Needs work

IS mentions Deprecate DateTime::formatExample but didn't see in the patch

Also was previously tagged for follow ups have those been opened?

nginex’s picture

Hi @smustgrave,

Patch #105 for drupal 10 has a deprecation.
Patch #107 for drupal 11 does not have deprecation because the method was completely removed.

Am I missing something?

smustgrave’s picture

11.x is the current development branch that D10 releases will be cut from. So the deprecation needs to be included.

nginex’s picture

Status: Needs work » Needs review
FileSize
8.85 KB
1.23 KB

@smustgrave thanks, I missed that momoment, here is updated patch.

gaurav_manerkar’s picture

Looks good to me

smustgrave’s picture

Status: Needs review » Needs work

There were a number of follow ups being discussed in 84-88 have those been opened?

acbramley’s picture

Issue summary: View changes
FileSize
13.37 KB
11.92 KB
acbramley’s picture

Needs accessibility review was added a long time ago (talked about PHP and JS changes which doesn't apply anymore), I don't feel like this new solution needs that anymore. It's also been through a usability review already.

smustgrave’s picture

Status: Needs review » Needs work

Thanks @acbramley for cleaning those tags up!

Everything looks good but can deprecation be updated for 10.2 vs 10.1 please.

Then think it's good to RTBC!

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

rpayanm’s picture

Status: Needs work » Needs review

Please review.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
quietone’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -datetime form element, -date format, -authored on

I'm triaging RTBC issues. I read the IS and the comments. I didn't find any unanswered questions or other work to do.

Thanks for making this review easy by having an up to date IS and screenshots.

Thanks for making the followup issues, #115. I think should be siblings of this one so they are easy to find and to consider the 'big picture' That is, they should have the same parent as this one.

I read the patch, not a code review.

  1. +++ b/core/lib/Drupal/Core/Datetime/Element/Datetime.php
    @@ -5,8 +5,8 @@
    +use Drupal\Core\Form\FormStateInterface;
    

    The re-sorting is out of scope.

  2. +++ b/core/lib/Drupal/Core/Datetime/Element/Datetime.php
    @@ -389,8 +384,14 @@ public static function validateDatetime(&$element, FormStateInterface $form_stat
    +   * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. HTML date
    +   *   input format should not be exposed to users, as browser widgets expose
    +   *   input differently, varying by vendor, locale, device type, etc.
    

    By practice, this is the same deprecation message as in the trigger_error. So, lets keep them the same.

    @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement.

  3. +++ b/core/lib/Drupal/Core/Datetime/Element/Datetime.php
    @@ -389,8 +384,14 @@ public static function validateDatetime(&$element, FormStateInterface $form_stat
    +   * @see https://www.drupal.org/project/drupal/issues/2791693
    

    There should be a blank line before the @see.

  4. +++ b/core/lib/Drupal/Core/Datetime/Element/Datetime.php
    @@ -389,8 +384,14 @@ public static function validateDatetime(&$element, FormStateInterface $form_stat
    +   * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. HTML date
    ...
    +    @trigger_error(__METHOD__ . ' is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. No replacement provided. https://www.drupal.org/project/drupal/issues/2791693', E_USER_DEPRECATED);
    

    This is close, but does not meet coding standards, it needs 'See'. And the version needs to be updated. Also changing the middle sentence to be consistent.

    is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/project/drupal/issues/2791693

    See @trigger_error() format

@rpayanm, this issue has been using a patch work flow for many years and can continue to do so. There is no need to create an MR.

Finally, removing tags per the guidelines and setting back to NW.

Edit: fix formatting

acbramley’s picture

acbramley’s picture

FileSize
8.34 KB
1014 bytes

Added CR and updated messages.

quietone’s picture

Status: Needs review » Reviewed & tested by the community

@acbramley, thank you for making the changes.

I have reviewed the changes and read the CR and setting back to RTBC.

catch’s picture

Adding some issue credit.

catch credited BlackBamboo.

catch credited rkoller.

catch credited shaal.

catch credited simohell.

catch’s picture

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 55efc8e and pushed to 11.x. Thanks!

Did my best with issue credit but this is a very long issue so apologies if any omissions.

catch’s picture

  • catch committed 5404ebfb on 11.x
    Issue #2791693 by nginex, acbramley, oknate, guaneagler, jan kellermann...
quietone’s picture

Published the CR

HitchShock’s picture

FileSize
7.19 KB

Just rerolled a patch for 9.5.11, without tests

kavbiswa’s picture

Patch for 10.1.x branch to fix the issue.

jonathan1055’s picture

@HitchShock @kavbiswa I don't think there is a plan to port this change to 10.x and 9.x? But I could be wrong.

HitchShock’s picture

Hi @jonathan1055
Sure, the solution will be released in the last Drupal version. We added these patches only for those who want to apply it to the older versions

Status: Fixed » Closed (fixed)

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

RichardDavies’s picture

Can someone please reroll the patch for Drupal 10.2.0?

acbramley’s picture

@RichardDavies no need, the patch was committed to 11.x before 10.2.0 was released and is therefore available in 10.2.0 :)

RichardDavies’s picture

@acbramley Ah, thank you for the clarification. I didn't understand how the 11.x branch worked and couldn't find this item listed in any of the 10.2x release notes so I assumed it wasn't in the 10.2 release. But I've just confirmed it is indeed there.

jonathan1055’s picture

Thanks @RichardDavies for confirming that the fix is in 10.2. I also did not know that the commit to 11.x would be silently ported to 10.x without some commit message being shown here. I'm sure many people knew this, but I didn't, and I always look for commit messages in the comments of the issues. Maybe I should also remember to search in the commit history of the branch.

Viewing https://git.drupalcode.org/project/drupal/-/commits/10.2.x and scrolling down to the right dates we see
commit in 10.2

The commit id 5404ebfb is exactly the same as the 11.x commit so I am still unsure whether this was a cherry-pick or whether the 11.x branch was actually the 'same' as the 10.2.x branch back then.

Martijn de Wit’s picture

jonathan1055’s picture

Thank you @Martijn de Wit, I knew there was something big going with branch naming, and that post explains it all.

paul121’s picture

I believe an unintended change was introduced with this issue. If a timestamp field provided a default value or default value callback, that field-level default value is no longer used as the default value in the entity form when creating a new entity. There is a check in TimestampDatetimeWidget::formElement() to only use the field item delta value if the entity is "not new": https://git.drupalcode.org/project/drupal/-/commit/5404ebfb11155b53dee0e...

A timestamp field with a default value might be a common use-case when the field is required (the user must provide a value) but the application would like to preset a default value to the current time for convenience. For an example see #3396419: Make timestamp required

acbramley’s picture

@paul121 nice find, I will try and track down in this issue why that change was made.

Are you able to create a new issue with your bug report and steps to reproduce from a fresh Drupal install?

acbramley’s picture

Originally added in #16 I'm not quite sure why, as you say default values are generally used on new entities so it doesn't make much sense to me. Unfortunate that we didn't pick it up sooner!

paul121’s picture