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
When using the styles in the node edit form we can get redundant labels that can just clutter the interface since the context where the plugin is used is well understood, however we might need a different label in the styles overview to clarify what type of style is it.
Also, when using the Style system we usually get some names that are inconsistent with lowercase and uppercase characters.
Proposed resolution
Add a label key to the style group definition that will be displayed to the user.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#18 | interdiff-3025786-16-18.txt | 674 bytes | johnchque |
#18 | label_group_definition-3025786-18.patch | 9.45 KB | johnchque |
| |||
#16 | interdiff-3025786-14-16.txt | 4.83 KB | johnchque |
#16 | label_group_definition-3025786-16.patch | 9.5 KB | johnchque |
#14 | interdiff-3025786-12-14.txt | 572 bytes | johnchque |
Comments
Comment #2
johnchqueComment #3
johnchqueThis should work. :)
Comment #5
johnchqueUsing the new short label in the summary now.
Comment #6
johnchqueWait no, this is not working properly.
Comment #7
johnchqueOK, the previous patch was not working because the first time that we loaded the styles we loaded them with either the label or the context label but not both. Now we have both and I added some methods for working with these. :)
Comment #8
johnchqueRemoving changes in demo.
Comment #9
johnchqueSo we can avoid displaying the Style in the behavior form if we have a context label for a group. :)
Comment #10
johnchqueOk, adding some comments and refactoring some lines. :)
Comment #11
johnchqueWe need to update the usage of this method.
Comment #12
johnchqueUpdating Style to be only lowercase. :)
Comment #14
johnchqueFixing tests. :)
Comment #15
BerdirHm, not sure about the key. Maybe widget_label?
this means you're doing the work twice, use an if/else instead.
hm, above you call it $title, here $group and the key/method is label. I'd use $label in both.
Having to duplicate this logic if trying multiple labels makes me sad, but it's tricky as above we have it combined with " style" and here we don't. But actually, that is kind of strange, as the shortened label here without style suffix possibly not enough context.
Wondering if we should just drop the style sufffix completely and simply add it to the group labels where we want to have it. Downside is that we would have a bit of duplication then in places like the style overview. Or we would alternatively add " style" also here, then we could do getGroupWidgetLabel() that would return the widget_label or fallback to "$label style"?
Or you could just do a isset($groups[$group_id]) ;)
Comment #16
johnchqueAddressed all comments above.
About 3. I decided to include the style suffix straight in the method getGroupWidgetLabel becuase I believe that we should keep consistent the labels between widget modes. :)
Comment #18
johnchqueThis should fix the test. Thanks @Berdir. :)
Comment #20
BerdirThanks. Committed.