EntityListBuilder should render the entity label

Created on 23 April 2015, about 10 years ago
Updated 26 January 2023, over 2 years ago

Problem/Motivation

EntityListBuilder currently just renders the entity operations as the only part of the row. This is not very useful as is, so it always needs to be extended. In the most trivial case, which is implemented several times in core, it is extended just to display a label in each row in front of the operations. This is cumbersome and makes the out-of-the-box experience for new entity types less than ideal.

Proposed resolution

Make EntityListBuilder render a label for each render in case the entity type provides a label key. That way EntityListBuilder can be used as is in core but also for contrib and custom entity types which do not need anything fancy.

As a second step we could consider making the label a link to the entity view page, but let's do that in a follow-up as that is non-trivial in its own right.

Remaining tasks

User interface changes

API changes

Beta phase evaluation

<!--Uncomment the relevant rows for the issue. -->
📌 Task
Status

Needs work

Version

10.1

Component
Entity 

Last updated about 8 hours ago

Created by

🇩🇪Germany tstoeckler Essen, Germany

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.

  • 🇷🇺Russia Chi

    I would also add ID column to the default list builder.

  • 🇷🇺Russia Chi

    I would also add ID column to the default list builder.

    Actually it does show entity ID even though the class name is EntityLabelListBuilder.

    I think it needs to be moved to the EntityListBuilder. If this is considered as BC break we should introduce the change in 11.x.

  • 🇬🇧United Kingdom joachim

    BC policy says:

    > Particular entity handlers should not be considered part of the public API

    -- that doesn't apply here, as this is a base class, and not a *particular* entity handler for a particular entity type.

    > In general, only interfaces can be relied on as the public API. With the exception of base classes, developers should generally assume that implementations of classes will change

    -- this does apply, as it's a base class.

    So I agree that making this change in the EntityListBuilder would be a BC break.

    However, we could do it in stages:

    - now: add the new EntityLabelListBuilder class. That way core and contrib can start using it.
    - 11.x: move the new code to EntityListBuilder, deprecate EntityLabelListBuilder
    - 12.x: remove EntityLabelListBuilder

  • 🇷🇺Russia Chi

    #53 Makes sense.

    I just submitted a patch to Entity API module that addresses the same issue.

    https://www.drupal.org/project/entity/issues/2913205#comment-14888086 Add a list builder extended from entitylistbuilder with atleast the name Needs review

  • Status changed to Needs review 25 days ago
  • 🇦🇲Armenia murz Yerevan, Armenia

    Moving to "Needs review" to get an answer for the MR's comment https://git.drupalcode.org/project/drupal/-/merge_requests/160#note_146560

  • The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • 🇬🇧United Kingdom joachim

    Tagging as novice as the fixes look pretty simple.

  • First commit to issue fork.
  • 🇧🇷Brazil brandonlira

    Hi @joachim,

    Fixed all issues flagged by @needs-review-queue-bot:

    • Removed unused imports
    • Fixed spacing before `array_merge(...)`

    Let me know if a rebase to 11.x is needed, happy to do it if required.

    Thanks!

  • 🇬🇧United Kingdom joachim

    Thanks!

    Unfortunately, I didn't read back far enough -- there is work needed on the bundle label too.

    And yes, this needs a rebase on 11.x too.

Production build 0.71.5 2024