- Issue created by @kostyashupenko
- 🇷🇺Russia kostyashupenko Omsk
I discussed with @sorlov a lot regarding this subject, here are several our thoughts:
1. From my personal point of view it was initially wrong idea to combine time and date into field type
Date
. It would be make sense to haveDatetime
field type for such cases.2. Moreover - we have field type called
Timestamp
. Try to add new field with such field type and find 10 differences from field typeDate
(in terms of render).3. If you will inspect form display render of
Date
type field withDate only
field setting enabled - you will seedatetime_wrapper
with title and form_element. Title is in<h4>
tag and this tag is hardcoded in twig template. It points me to the thought that there can be potentially SEO risks. But that's not all -> if we haveDate only
field setting enabled, why we need datetime-wrapper in that case? The easiest (and obvious) way is to just display label + input. Right now we have datetime-wrapper always applied, no matter if settingDate only
enabled or not. Moreover - visually maybe h4 title is looking like a label, but actually it's not. It doesn't havelabel
html tag and it's not clickable (but it should be clickable to get focus on the input element).Now what we could do with all that. Several proposals:
1. We could rewrite field types and have 3 different field types for different needs:
Date
(showing date input only, always label + input html tags),Time
(for showing input time only + label),Datetime
(when we need both, and keep datetime-wrapper for that).2. We could kick somehow
datetime-wrapper
wrapper for existingDate
field if settingDate only
enabled. And show only regular label + input html tags.3. We could keep everything as it is, but only remove
Title
fromdatetime-wrapper
and unhide original label html tag (which is hidden right now). - 🇷🇺Russia kostyashupenko Omsk
Tried webform → module with
Date
element as a reference.This is exactly render i want to have for the
Date only
field: - 🇷🇺Russia kostyashupenko Omsk
Also they are splitting
Date
andDate/time
elements - Status changed to Needs review
over 1 year ago 8:57am 28 August 2023 - last update
over 1 year ago 30,056 pass, 2 fail - 🇷🇺Russia sorlov
Several proposals:
....
3. We could keep everything as it is, but only remove Title from datetime-wrapper and unhide original label html tag (which is hidden right now).This can be done as quick fix on Drupal\Core\Datetime\Element\Datetime to show as Title for Date sub-element instead of rendering title in datetime-wrapper theme template
Attached patch with this solution
The last submitted patch, 7: 3383646-7.patch, failed testing. View results →
- Status changed to Needs work
over 1 year ago 1:47pm 28 August 2023 - 🇬🇪Georgia maximkashuba Batumi
Labels for inputs are always present, but can be visually hidden (accessible to screen readers) if the field has multiple cardinality.
There are 2 scenarios: single and multiple cardinality field. For multiple fields the labels are visually hidden by the WidgetBase class, but for fields with a single element, the label is displayed as required by the task.
The Datetime field is flexible and can have 2 variants: date (1 input) or date and time (2 inputs), additionally it has own custom form render element that results in a slightly different rendering order, adds
#title_display => 'invisible'
property and misses logic of WidgetBase class hiding labels for multiple fields.So there are options:
- Single date field/show label
- Multiple date fields/hide label
- Single date and time field/hide labels
- Multiple date and time field/hide labels
An additional example of a multiple simple text field is attached.
- last update
over 1 year ago Patch Failed to Apply - 🇬🇪Georgia maximkashuba Batumi
Labels for inputs are always present, but can be visually hidden (accessible to screen readers) if the field has multiple cardinality.
There are 2 scenarios: single and multiple cardinality field. For multiple fields the labels are visually hidden by the WidgetBase class, but for fields with a single element, the label is displayed as required by the task.
The Datetime field is flexible and can have 2 variants: date (1 input) or date and time (2 inputs), additionally it has own custom form render element that results in a slightly different rendering order, adds
#title_display => 'invisible'
property and misses logic of WidgetBase class hiding labels for multiple fields.So there are states:
- Single date field/show label
- Multiple date fields/hide labels
- Single date and time field/hide label
- Multiple date and time field/hide labels
An additional example of a multiple simple text field is attached.
- last update
over 1 year ago 30,056 pass, 2 fail - Status changed to Needs review
over 1 year ago 2:57pm 28 August 2023 The last submitted patch, 11: 3383646-11.patch, failed testing. View results →
- Status changed to Needs work
over 1 year ago 4:33am 29 August 2023 - 🇷🇺Russia sorlov
Changes in datatime-wrapper template also affect datelist form element and make ElementsLabelsTest::testTitleEscaping() test fail for it
- 🇷🇺Russia ilya.no
Problem is that if we use date fields on custom form, then they don't have titles with current patch. For testing I've copied FormTestLabelForm into custom module and saw, that only `date` form element has title. That's why test fails.
My solution is to use `form_element` as theme wrapper instead of `datetime_wrapper`, because we need usual label and input HTML structure. In my patch I remove occurencies of `datetime_wrapper`. Failed test runs fine locally after my update. I've also checked all 4 cases from #11 comment on node add form and titles are fine.
- Status changed to Needs review
over 1 year ago 3:02pm 26 October 2023 - last update
over 1 year ago 30,438 pass - 🇺🇸United States smustgrave
If the solution is going to change the issue summary will have to be updated.
Also a CR will probably be needed for other themes to delete their templates.
- Status changed to Needs work
over 1 year ago 5:05pm 30 October 2023 - Status changed to Needs review
over 1 year ago 1:36pm 1 November 2023 - 🇷🇺Russia ilya.no
I've been pointed by @sorlov to the issue with duplicating title for date only case, so attaching another patch with the fix for datetime field widget. It adds logic to use title_display setting from the element, if there is no such setting already.
I've updated issue summary, but for the change record, I think, that we need to agree on one of ours solutions first and then add CR if necessary. - last update
over 1 year ago 30,483 pass - Status changed to Needs work
over 1 year ago 2:42pm 6 November 2023 - 🇺🇸United States smustgrave
Looking at the IS there are 3 solutions, could it be highlighted which approach is being proposed.
Also with template changes will need a CR.
- 🇮🇹Italy finex
Hi, I've found a couple of related issues which could be considered when fixing this request.
- https://www.drupal.org/project/drupal/issues/2978727 🐛 Use current time setting for the timestamp widget Needs work
- https://www.drupal.org/project/drupal/issues/2978467 →