The entity-add-list template omits link attributes

Created on 16 December 2016, over 8 years ago
Updated 13 June 2025, about 2 months ago

It turns out that when you render Seven's entity-add-list.html.twig template, you cannot set additional attributes on the bundle names, because Seven does this in the template:

    {% for bundle in bundles %}
      <li class="clearfix"><a href="{{ bundle.add_link.url }}"><span class="label">{{ bundle.label }}</span><div class="description">{{ bundle.description }}</div></a></li>
    {% endfor %}

The problem is Seven unpacking the bundle.add_link variable, which *should* be unnecessary because it implements RenderableInterface. But anyhoo, because it unpacks the variable, any attributes set on the link's URL object are thrown right out the window. We need something like this:

    {% for bundle in bundles %}
      <li class="clearfix"><a{{ create_attribute(bundle.add_link.url.options.attributes) }} href="{{ bundle.add_link.url }}"><span class="label">{{ bundle.label }}</span><div class="description">{{ bundle.description }}</div></a></li>
    {% endfor %}

Special thanks to Wim Leers for heroically tracing this and suggesting the fix.

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇺🇸United States phenaproxima Massachusetts

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