Test that all form elements have a title for accessibility

Created on 6 October 2010, almost 15 years ago
Updated 23 April 2024, over 1 year ago

Issue summary updated through comment #142.

Problem

To ensure that all form elements are accessible, we need a mechanism to ensure that #title is set up for all the form elements that should use it, so that defining that form element without using #title is not possible.

There was a proposal to create an abstracted "Property Validation API" that can be used to verify that all the required properties of a certain element have been set properly. This was rejected since the feature was only useful when developers are building the form, and is needless code execution otherwise.

Proposed resolution

In #128, tstoeckler suggested a core test that would check every module's forms and ensure that relevant form elements have a #title attribute. This would prevent any new core from being added without necessary #title attributes, since those forms would not pass this test.

Remaining tasks

  1. mikey_p suggested on IRC, Current AccessibilityTest checking may probably fail for quite a few forms, notably any entity form. Need to do something to get all the entity forms via the entityform system / EntityFormBuilder. Here's some code that attempts to work with any entity form: http://cgit.drupalcode.org/formblock/tree/src/Plugin/Block/EntityFormBlo...
  2. Reroll #134 removing sections that have been solved by #1987726: Convert language content page related callback to new style controller β†’
  3. or possibly start over.
<!-- See https://drupal.org/core-mentoring/novice-tasks for tips on identifying novice tasks. Delete or add "Novice" from the Novice? column in the table below as appropriate. Uncomment tasks as the issue advances. Update the Complete? column to indicate when they are done, and maybe reference the comment number where they were done. -->

Original report

In #882694: Add missing form element titles for accessibility β†’ @Sun suggested that a mechanism be put in place to ensure that all form fields have a #title.

the proper fix for D8 is to additionally require a non-empty #title for all form elements via form_builder(), throwing an exception or error message if one without is encountered, so as to ensure that every form is accessible.

EDIT: That is, because Form API is not able to throw a form validation error for a form element without #title. You simply see the same form, without any error message.(http://drupal.org/node/882694#comment-3513452)

πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component
FormΒ  β†’

Last updated 7 days ago

Created by

πŸ‡¨πŸ‡¦Canada Everett Zufelt

Live updates comments and jobs are added and updated live.
  • Accessibility

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

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

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.

  • First commit to issue fork.
  • Merge request !7659Accessible titles β†’ (Open) created by nicxvan
  • Pipeline finished with Failed
    over 1 year ago
    Total: 177s
    #153869
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    I've updated this to an MR. I had to handle the removal of Book.

    I also changed the deprecation removal notice to 11.x I'm not sure if that is correct.

    Hiding all patches.

  • Pipeline finished with Failed
    over 1 year ago
    Total: 162s
    #153878
  • Pipeline finished with Failed
    over 1 year ago
    Total: 176s
    #153879
  • Pipeline finished with Failed
    over 1 year ago
    #153880
  • Pipeline finished with Failed
    over 1 year ago
    Total: 178s
    #153884
  • Pipeline finished with Canceled
    over 1 year ago
    Total: 189s
    #153887
  • Pipeline finished with Running
    over 1 year ago
    #153889
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Ok this still needs work there are a lot of test failures.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • Pipeline finished with Failed
    21 days ago
    Total: 1057s
    #579947
  • πŸ‡ΊπŸ‡ΈUnited States kentr Durango, CO

    There are some uses of #label in the Content Translation and Language modules. Removing it (comments #197 & #202) caused several Exception: Warning: Undefined array key "#label" errors in tests.

    Another error is caused by the missing #title for the test element in WeightTest.php.

    I'll push an update that resolves these.

  • Pipeline finished with Failed
    20 days ago
    Total: 147s
    #580631
  • Pipeline finished with Failed
    20 days ago
    Total: 716s
    #580659
  • πŸ‡ΊπŸ‡ΈUnited States kentr Durango, CO

    Question about the new validation code:

    The code checks for the aria-labelledby attribute but not the aria-label attribute.

    Was aria-label intentionally omitted? It's a valid method (though not preferred) of providing an accessible name, and it looks like core uses it for fields.

    I'm also working on other test failures.

  • Pipeline finished with Failed
    16 days ago
    Total: 487s
    #584681
  • Pipeline finished with Success
    16 days ago
    #585433
  • Pipeline finished with Failed
    13 days ago
    Total: 616s
    #587391
  • πŸ‡ΊπŸ‡ΈUnited States kentr Durango, CO

    It looks like the original plan was to check for non-empty #title properties, but the MR only checked with isset().

    Empty text doesn't provide an accessible name, so I changed the check to fully disallow empty #title properties. This caused a lot of new errors. Some of them are from πŸ› Content: Publishing status (grouped) is missing labels for inputs Active . I think the others are from the Views exposed filter forms themselves.

    I also added aria-label to the conditions.

Production build 0.71.5 2024