Make List field keys available to the field.html.twig

Created on 3 July 2023, 12 months ago

Problem/Motivation

In the field.html.twig of a list field, the list item keys are not available to Twig, while they are available within the parent entity. The keys are often used to create CSS classes out of it.

Especially when Layout Builder is used, its kind of impossible to print the field in the ENTITY/node.html.twig, to print the field content with the key-Class right there. So the field template is a solid way around this problem.


This is what we currently have:

To get the keys inside the field.html.twig, you have to do something like this:

element['#object'].get('field_seminar_type').value

Steps to reproduce

Proposed resolution

Make the keys available in the render array.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

✨ Feature request
Status

Active

Version

11.0 πŸ”₯

Component
OptionsΒ  β†’

Last updated 27 days ago

No maintainer
Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024