table columns for multi instance fields #18220
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Steps to reproduce:
plainText;et1andet2plainTextfield 3 times:et1, “Single 2” withet2and “Single 3” withet1If you go to the entry index page, to the “Singles” source and click the “View” button next to the search input, you can see that the “Plain text” checkbox appears only once, since its handle is not overridden and “headline” and “topline” each show twice
How it currently works:
If you add the same field to a field layout more than once, each of those field instances gets its own checkbox in the Table Columns list, because it has an overwritten handle: https://github.com/craftcms/cms/blob/5.8.21/src/services/ElementSources.php#L458-L467; If you are adding the same field twice, it‘s safe to assume that you‘d want the label of that field to be different for each case, just like you have: “text”, “headline”, “topline”, so it all looks and works as expected.
The same rule applies when you‘re viewing a source that has multiple field layouts. If each of your singles uses a different entry type, then each field is a different instance and therefore shows as a separate checkbox.
We had a similar report for the condition builder functionality, and the most recent work was done here: #15781. In that case, we‘ll only show duplicate names of the same field if the name is the same, but the handle is different. Additionally, if the user has ‘showFieldHandles’ turned on, we‘ll show the field handles.
This PR:
This PR makes the table column checkboxes and actual table columns follow the same logic as the condition builder. Each combination of the field uid (actual global field uid), field layout element label and field layout element handle is the same - only show one checkbox table columns checkbox and only show one column for it in the table. This affects the element index table view (and inline editing), the “table columns” checkboxes under the “View” button, and the “Customize Sources” modal.
Before:


After:


Related issues
#18209