Display 'required' validation errors for form elements that do not provide a #title

Created on 4 September 2015, about 9 years ago
Updated 23 January 2023, over 1 year ago

Problem/Motivation

If "required" validation on a field without a #title fails, we display an error region with no message.

Submitting as critical because we just silently fail on a form submission which can give the impression the submission was successful to the end user.

To reproduce the problem,

  1. Create or edit a view with a block display. For example, use "Who's online block".
  2. Add an exposed text filter. For example, add a filter on "Name (raw)".
  3. Make the field required.
  4. Do not supply a default value.
  5. Remove the Label.
  6. Under "Advanced", change "Use AJAX" to "Yes".
  7. Save the view.
  8. Enable the Contact module.
  9. Add the block with the exposed filter to the contact page (/contact/feedback by default).
  10. Visit the contact page.

When the page loads, even before you try to submit any form, you should see the empty error message.

Instead of using the Contact module, you could use a view with both page and block displays. Then add the block to the page created by the same view. There are alternative steps to reproduce in Comment #61.

The current behavior fails several WCAG requirements:

  1. (Level A): see Error Identification: Understanding SC 3.3.1
  2. (Level A): see Labels or Instructions
  3. (Level AA): see Error Instructions
  4. (Level AA): see Error Prevention (Legal, Financial, Data)
  5. (Level A): see Name, Role, Value

See Comments #62 and #64 for more information on these accessibility issues.

Proposed resolution

Display the ID of the form element as opposed to displaying nothing so it is clear that validation failed to developers (and end users - if developers don't find this bug in their own testing)

Remaining tasks

  • Accessibility review (notes in Comments #62 and #64 about how to assess this).
  • Decide on final wording. See discussion in Comment #61.

User interface changes

An error message now appears when validation fails:

or (with the inline_form_errors module enabled and the wording suggested in Comment #61)

API changes

N/A

Data model changes

N/A

πŸ› Bug report
Status

Needs work

Version

10.1 ✨

Component
FormΒ  β†’

Last updated about 1 hour ago

Created by

πŸ‡³πŸ‡±Netherlands stefan.r

Live updates comments and jobs are added and updated live.
  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

  • Triaged core major

    There is consensus among core maintainers that this is a major issue. Only core committers should add this tag.

  • Accessibility

    It affects the ability of people with disabilities or special needs (such as blindness or color-blindness) to use Drupal.

  • Needs accessibility review

    Used to alert the accessibility topic maintainer(s) that an issue significantly affects (or has the potential to affect) the accessibility of Drupal, and their signoff is needed (see the governance policy draft for more information). Useful links: Drupal's accessibility standards, the Drupal Core accessibility gate.

Sign in to follow issues

Comments & Activities

Not all content is available!

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

Production build 0.71.5 2024