Move multivalue field's label out of rendered table to a separate <label> to provide HTML consistency

Created on 9 November 2014, over 10 years ago
Updated 13 May 2025, 4 days ago

Problem/Motivation

In entity forms, fields with cardinality > 1 are rendered in a table with the field's label as the table header. This creates inconsistent HTML between single and multiple value fields. This causes several problems:

  • As a themer you have to theme two set of selectors with lots of overrides to get a similar layout
  • Changing a field from single to multi value forces you restyle the CSS again
  • The field's label looks different in Bartik and Seven between single and multiple values making it harder for the user to build familiarity of what really is a field's label
  • Issues like #2318757: Make position of #description configurable via the API for form field widgets β†’ is forced to render the label differently. Should the label be rendered before the table and have the help text between, or should the help text be rendered as a stand-alone table row?

Although it kind of makes sense to have the label as a table header as it's already rendered in a table, overall it causes more troubles than benefits. These images illustrate two text fields, one as single value, the other as multi value. The difference is vast both visually and in the DOM.


Proposed resolution

  • Move the field's title out of the rendered table in template_preprocess_field_multiple_value_form() into a <label> just like single value fields.
  • Remove the table header altogether, which includes the Order column header when "Show row weights" are hit.

Which will result in something like this:

Remaining tasks

  • Agree on this actually being an issue.
  • Come to an agreement on the solution.
  • Get some accessibility eyes on the removal of the table header. One possible solution is to add an accessibility-related attribute to the weight columns.

User interface changes

In entity forms, multiple values will have the field's label rendered the same way as single values. The exception is field's that has its own handling of multi value fields (options.module et.al.)

API changes

None AFAICS.

πŸ“Œ Task
Status

Closed: duplicate

Version

11.0 πŸ”₯

Component

user.module

Created by

πŸ‡³πŸ‡΄Norway kaare TromsΓΈ

Live updates comments and jobs are added and updated live.
  • 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