Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Quoting @Bojhan in #1043198-37: Convert view modes to ConfigEntity:
We don't expose machine_name in tables generally
...but we currently do in the EntityListController. See EntityListController::buildHeader.
Proposed resolution
Remove the machine name from table generated by EntityListController
.
Remaining tasks
Write patch. :-)
User interface changes
No more "Machine name" in Entity listings by default.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#21 | drupal-remove-machine-name-1831890-21.patch | 14.27 KB | chishah92 |
#16 | drupal-remove-machine-name-1831890-16.patch | 5.55 KB | markpavlitski |
#14 | drupal-remove-machine-name-1831890-14.patch | 825 bytes | markpavlitski |
Comments
Comment #1
larowlanTagging
Comment #2
larowlanComment #3
RobW CreditAttribution: RobW commentedIf the machine names for nodes, view modes, fields, etc. aren't shown in the ui, how am I as a developer supposed to find them out? Inspect class names and guess from there, or insert a kpr() every time I want to write hook_anything? This seems like a dx regression to me.
Comment #4
tstoecklerWell, they would be shown when you click on the edit link for an entity (view mode, node type, ...), just not in the overview listing.
Comment #5
tim.plunkettSeeing it in the Field UI is helpful.
The Views listing has the machine name in the title text when hovering on the row.
Comment #6
RobW CreditAttribution: RobW commentedIIRC, the concern is that the machine name clutters the ui and overloads the non-technical user with information. But we want the developer/site builder to have access to this information, preferably on overview and edit pages.
Having to hover a link and remember a string, or click through to a new page to be able to copy isn't optimal, especially if the machine name is something long and repetitive (as happens with Drupal sometimes :D ). Title attribute text isn't optimal for many users for a number of reasons either.
Like Tim mentioned, seeing the field machine names which often differ greatly from the human readable name in the UI is extremely useful if you want to quickly grok what the site's field naming scheme is, or check which fields were created and can be destroyed easily with the UI and which are provided by modules -- I and a few developers I know use the Title module naming scheme, where if a field is required and provided by a custom module we name it
{name}_field
instead offield_{name}
. Probably not widespread practice, but another real world example.How about all entity machine names are listed visually and selectably underneath their human readable names when a new permission is enabled, so you can scope machine names to only the roles that are likely to need them?
Comment #7
yoroy CreditAttribution: yoroy commented> How about all entity machine names are listed visually and selectably underneath their human readable names when a new permission is enabled, so you can scope machine names to only the roles that are likely to need them?
I don't understand this. What does this mean?
> …click through to a new page to be able to copy isn't optimal
Nothing is ever optimal. It's about trade-offs. I don't think we should be optimizing the discoverability of the machine name at the cost of cluttering overview pages.
Comment #8
tstoecklerThere two things proposed here:
1. Add a permission such as "View machine-readable names" so that the site admin can choose who sees them and who doesn't.
2. Instead of having the machine names in a separate column, show them below the human-readable name/label (for those who are allowed to see them per 1.).
I first thought that 1. was a pretty nifty idea, but then I realized that the 80 percent use-case is probably a single administrator and the administrative account (uid == 1) bypasses all access checks so he/she will always see the machine names. Hmm...
Comment #9
RobW CreditAttribution: RobW commentedtstoeckler that's a good point. I would say it's not quite 80%, since every site built by a firm/developer for an end user will own the superuser themselves and give their clients purpose built roles so they can't destroy the site, but enthusiasts and the mythical admin + nontechnical end user hybrid trying out the system themselves would be stuck with the full developer view.
We could do something similar with a module and the admin/config page instead of using permissions. That's a little more complexity on the api end.
Comment #10
yoroy CreditAttribution: yoroy commentedAdding a permission comes down to pushing of the decision off somewhere else, to an out-of-context place where it will be very hard to understand what the whole concept means. The name 'machine name' already implies that this isn't user-facing material. I don't think you can lump the whole group of site-builders in as a target audience, it's only for those who write actual code as well, which is a sub-set of the site builders group.
Showing it below the name is tricky too: it would increase, almost double, the height of each row for 1, relatively unimportant piece of data, thus halving the information densitiy of the screen. Lets not do that, look at the views listing for the amount of clutter that approach can lead to :)
I understand the need to have it available somewhere in the ui, but I haven't seen a convincing argument yet to stop us from moving it away from the listing into the individual entity settings form.
Comment #11
YesCT CreditAttribution: YesCT commentedJust adding a note that #1833104: Add a "translatable" column to Manage Fields is about adding a column.
Comment #12
fenda CreditAttribution: fenda commentedI just thought of a flaw with this. In a listing you can have multiple items with the same label. There would be no way to differentiate between those items without a machine_name, right?
Comment #13
tstoecklerIn theory that sounds like a problem, but I think if you have two items with the same label you're doing it wrong ©. Labels are supposed to be "human-readable" and "Foo" vs. "Foo" is by no means that.
Comment #14
markpavlitski CreditAttribution: markpavlitski commentedThe attached patch simply removes the machine name column.
EntityListController can be extended by other modules to add this column in, if it's needed in special cases.
Comment #16
markpavlitski CreditAttribution: markpavlitski commentedThis patch also adjusts the test scripts to match.
Comment #17
socketwench CreditAttribution: socketwench commentedNovice issue cleanup.
Comment #19
jhedstromNot sure if this is still an issue or not since the list builders were split out per-entity type. It may be an issue on some.
Comment #20
chishah92 CreditAttribution: chishah92 at Blisstering Solutions commentedComment #21
chishah92 CreditAttribution: chishah92 at Blisstering Solutions commentedRerolled the patch.
Comment #22
tstoecklerThat patch mostly looks like a revert of ancient core commits, probably due to a faulty merge. I think it makes sense to start from scratch here, in case this is still an issue.
Comment #23
chishah92 CreditAttribution: chishah92 at Blisstering Solutions commentedComment #25
hitesh-jain CreditAttribution: hitesh-jain at Acquia commentedComment #26
hitesh-jain CreditAttribution: hitesh-jain at Acquia commentedI could apply the patch, so no reroll is needed. Applied against 8.2.x branch .
Removed Needs Reroll Issue tag.
Comment #27
jhedstromI'm not sure if this is even an issue anymore. I couldn't find any core list builders (aside from in the entity_test module) that were exposing the machine name.
Comment #41
smustgrave CreditAttribution: smustgrave at Mobomo commentedThink this can be closed as there has been no follow up since moving to PNMI 7 years ago.
If still a valid task please reopen updating the issue summary.
Thanks!