Create item list field formatter for displaying ordered and unordered lists

Created on 20 December 2022, about 2 years ago
Updated 20 September 2024, 3 months ago

Problem/Motivation

As a site builder I am unable to output list fields using HTML list markup. i.e. <ul> <ol>

Steps to reproduce

Add any of the following field types to any fieldable entity:
text list
float list
number list
entity reference

OR

Any field type that implements the FieldItemListInterface really.

Proposed resolution

Introduce a field formatter in https://git.drupalcode.org/project/drupal/-/tree/10.1.x/core/lib/Drupal/...
That utilizes theme('item_list')

Much like this abandoned module does https://git.drupalcode.org/project/field_item_list/-/tree/8.x-1.x

FYI item-list.html.twig lives in the system module.

Remaining tasks

Add 4 tests, with at least 3 assertions each.

1. Check that entity_reference fields render as expected for each option (csv, ol, ul)
2. Check that list_float fields render as expected for each option (csv, ol, ul)
3. Check that list_string fields render as expected for each option (csv, ol, ul)
4. Check that list_integer render as expected for each option (csv, ol, ul)

User interface changes

Allow site builders to output field types that use FieldItemListInterface as HTML lists.

API changes

Additions, no subtractions.

Data model changes

N/A

Release notes snippet

Site builders can now select the following options when choosing how to display entity reference, text list, number list, float list field types:

Comma, a comma separated list
Unordered list, an HTML <UL> list
Ordered list, an HTML <OL> list

See <Merge Commit HASH> for the code change.

✨ Feature request
Status

Needs work

Version

11.0 🔥

Component
Field  →

Last updated 1 day ago

Created by

🇺🇸United States trackleft2 Tucson, AZ 🇺🇸

Live updates comments and jobs are added and updated live.
  • Needs framework manager review

    It is used to alert the framework manager core committer(s) that an issue significantly impacts (or has the potential to impact) multiple subsystems or represents a significant change or addition in architecture or public APIs, and their signoff is needed (see the governance policy draft for more information). If an issue significantly impacts only one subsystem, use Needs subsystem maintainer review instead, and make sure the issue component is set to the correct subsystem.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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.

Production build 0.71.5 2024