With Inline Form Errors module enabled errors on datetime render (form) elements are repeated.
The error should just be thrown once.
Or if there is an specific error for one of the input/selects it should be shown only for that part of the element.

Before:

CommentFileSizeAuthor
#46 2827034-nr-bot.txt5.79 KBneeds-review-queue-bot
#38 Screenshot_20200414_122224.png13.72 KBjohnchque
#36 Screen Shot 2020-01-30 at 1.48.59 PM.png113.39 KBmpdonadio
#35 2827034-35.patch15.7 KBmpdonadio
#35 2827034-35-TEST-ONLY.patch12.11 KBmpdonadio
#33 datelist_inline_form_errors_are_repeated-2827034-31-interdiff.txt1.16 KBLuke.Leber
#32 datelist_inline_form_errors_are_repeated-2827034-31.patch15.7 KBLuke.Leber
#30 datelist_inline_form_errors_are_repeated-2827034-30-interdiff.txt1.24 KBBerdir
#30 datelist_inline_form_errors_are_repeated-2827034-30.patch15.65 KBBerdir
#27 datelist_inline_form_errors_are_repeated-2827034-27.patch15.47 KBLuke.Leber
#23 interdiff-2827034-17-23.txt2.59 KBjohnchque
#23 datelist_inline_form_errors_are_repeated-2827034-23.patch15.47 KBjohnchque
#17 Screenshot from 2018-04-04 08-44-13.png42.77 KBjohnchque
#17 interdiff-2827034-15-17.txt8.56 KBjohnchque
#17 datelist_inline_form_errors_are_repeated-2827034-17.patch15.82 KBjohnchque
#15 Screenshot from 2018-04-03 16-30-17.png38.8 KBjohnchque
#15 interdiff-2827034-7-15.txt5.25 KBjohnchque
#15 datelist_inline_form_errors_are_repeated-2827034-15.patch7.09 KBjohnchque
#11 Bildschirmfoto_2017-11-30_um_11.47.18.png37.78 KBBerdir
#7 datelist_inline_form_errors_are_repeated-2827034-7.patch1.35 KBKrilo_89
datelist_ife.png21.32 KBdmsmidt
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dmsmidt created an issue. See original summary.

dmsmidt’s picture

Priority: Normal » Minor

I've quickly looked through core and it looks like this element is hardly or even never used.
And furthermore the element can't be chosen via the admin interface.

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

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now 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.

Nitebreed’s picture

Priority: Minor » Normal

This element can be added with the Webform module via the admin interface. Therefore, I'm resetting the priority.

dmsmidt’s picture

Issue tags: +sprint
ericmulder1980’s picture

Assigned: Unassigned » ericmulder1980

Working on this at the a11y-sprint-2017

Krilo_89’s picture

Also worked on this issue at the a11y-sprint-2017. (@ericmulder1980 knows about this)

Changing:
'#error_no_message' => FALSE,
to:
'#error_no_message' => TRUE,
results in 1 error message on the parent element and no error messages on child elements. In that way the Datelist elements render without multiple repeated errors between the elements. However, to due the way error messages bubble up the possible individual errors per date part are not visible anymore.

So next to showing only a single error message for the Datelist field we also have to let the user know which part (or parts) is/are problematic.
That's why the message is changed to the one below, where the errors for the child elements were added:
$form_state->setError($element, t('The %field date is incomplete. A value must be selected for %parts.', ['%field' => $title, '%part' => implode(', ', $all_empty)]));

Krilo_89’s picture

Status: Needs review » Needs work

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

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now 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.

Berdir’s picture

There is a similar problem for date range fields with date form elements, for example when entering an end date that is before the start date.

Separate issue I guess?

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

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now 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.

mpdonadio’s picture

Component: inline_form_errors.module » datetime.module
Assigned: Krilo_89 » Unassigned
Issue tags: +Needs tests
Related issues: +#2927452: Date range fields have repeating validation messages with IFE

We need a test to demonstrate this and prevent regressions.

Given the size of the current functional datetime/daterange field tests, and since IFE isn't in the minimal or standard profiles, I would prefer a standalone test that enables IFE and tests the bug.

I wouldn't object to merging this with #2927452: Date range fields have repeating validation messages with IFE.

johnchque’s picture

Assigned: Unassigned » johnchque

Will work on this.

johnchque’s picture

Adding the patch of #2927452: Date range fields have repeating validation messages with IFE. Had some problems with my local env.

I've noticed something here:

With IFE, the field is refered as Year only, not to every field. Will investigate.

I have closed the other issue as duplicated so we can continue in this one only.

Status: Needs review » Needs work
johnchque’s picture

FIxing tests, adding specific tests for IFE, added title to the field so the problem described in #15 is fixed.

Berdir’s picture

Status: Needs review » Needs work

I don't think the title should be visible like that. Is there any way to achieve that without making it visible? I guess we could use #label_display hidden?

mgifford’s picture

@Bedir do you want it to just say "A value must be selected for year, hour minute, ampms"?

Given that it is right next to the label & input I would be fine with that.

johnchque’s picture

@mgifford, @Berdir refers to the title "Test (value 1)" and "Test (value 2)" that were not present in the screenshot that I uploaded in #15.

Titles in bold where added with the last change I made:

$element['#title'] = static::getElementTitle($element, $complete_form);

To use the correct title in the top message that inline form errors displays. I tried following the suggestion of @Berdir but it seems that the title is still being displayed.

mgifford’s picture

Thanks for the clarification @yongt9412.

Berdir’s picture

Title: DateList inline form errors are repeated » DateList and date range inline form errors are repeated
+++ b/core/lib/Drupal/Core/Datetime/Element/Datelist.php
@@ -258,6 +258,7 @@ public static function processDatelist(&$element, FormStateInterface $form_state
       }
 
+      $element['#title'] = static::getElementTitle($element, $complete_form);
       $element['#attributes']['title'] = $title;

I think we should revert that and open a follow-up to improve the label.

The problem is that this is not a standard form element where #title_display works, it is a custom template datetime wrapper.

At the same time, the title is detected in \Drupal\Core\Form\FormElementHelper::getElementTitle().

I only see two ways out, either we add something to respect #title_display or something similar to those preprocess/template functions (I think we could add it to preprocess and it should be respected automatically be all templates unless they do something crazy) or we add a special property that we can check in that method.

But I think we can deal with that in a separate issue and focus on fixing the duplicates here.

johnchque’s picture

So reverting the title addition.

Opening follow-up: #2958626: Display the field label in IFE messages with datelists

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.

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.

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.

Luke.Leber’s picture

Reroll for 8.9 with a small change fixing a typo.

-        $form_state->setError($element, t('The %field date is incomplete. A value must be selected for %parts.', ['%field' => $title, '%part' => implode(', ', $all_empty)]));
+        $form_state->setError($element, t('The %field date is incomplete. A value must be selected for %parts.', ['%field' => $title, '%parts' => implode(', ', $all_empty)]));
Luke.Leber’s picture

Status: Needs review » Needs work
jhedstrom’s picture

Issue tags: -Needs tests

The tests are failing due to some deprecation notices, so the test will need updating to address those.

Berdir’s picture

Status: Needs review » Needs work
Luke.Leber’s picture

Luke.Leber’s picture

Luke.Leber’s picture

Status: Needs work » Needs review
mpdonadio’s picture

Re-running #32 and just the new test. Also doing a manual test.

mpdonadio’s picture

Assigned: mpdonadio » Unassigned
Status: Needs review » Needs work
FileSize
113.39 KB

Patch doesn't work for Datetime Range fields configured for the Datelist form entry:

johnchque’s picture

Assigned: Unassigned » johnchque

Gonna review this.

johnchque’s picture

Assigned: johnchque » Unassigned
FileSize
13.72 KB

OK, so it seems that the message not being displayed is somehow different.

The code in Drupal\datetime_range\Plugin\Field\FieldWidget\DateRangeWidgetBase adds an error message that checks whether the end date is before the start date and throws an error if that is the case. The tests added here for date range are passing as we are testing that message.

However, that file DateRangeWidgetBase extends from DateTimeWidgetBase which uses a type=>datetime field. This field has its own validation but it is not displayed in the DateRange field. Not sure if that is part of the scope of this issue as we just want not to have duplicated error messages in these fields, which is the case.

I believe that opening a follow-up to address that problem would be best. Thoughts?

This is how the error message is displayed.

johnchque’s picture

Status: Needs work » Needs review

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.

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.

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.

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.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
5.79 KB

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mgifford’s picture

Issue tags: +wcag311

I think this would confuse the user so listing it as https://www.w3.org/WAI/WCAG21/Understanding/error-identification.html

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.