Problem/Motivation
I was testing Drupal 8.0.x this morning and discovered that when you create a view mode it doesn't automatically show up in the Manage Display section of a content type.
see here:
I expect my new display mode "One more time" to display among the available choices. It IS accessible if I use it's specific url but I don't see the link for it.
Proposed resolution
It was pointed out that this problem can be fixed if the cached list of local tasks is cleared when view modes are created.
Needs:
- Clear cache when view modes are created
- Add a test to check if the view mode can be displayed after it's created
Remaining tasks
User interface changes
API changes
Original report by @cosmicdreams
I was testing Drupal 8.0.x this morning and discovered that when you create a view mode it doesn't automatically show up in the Manage Display section of a content type.
see here:
I expect my new display mode "One more time" to display among the available choices. It IS accessible if I use it's specific url but I don't see the link for it.
It was pointed out that this problem can be fixed if the cached list of local tasks is cleared when view modes are created.
Comment | File | Size | Author |
---|---|---|---|
#21 | 2341455-21.patch | 3.12 KB | swentel |
#20 | 2341455-20.patch | 3.16 KB | swentel |
Drupal issue.PNG | 67.33 KB | cosmicdreams | |
#10 | 2341455-9.patch | 953 bytes | swentel |
#13 | 2341455-13.patch | 3.14 KB | swentel |
Comments
Comment #1
larowlanComment #2
dawehnerYeah this is just a cache clear problem, though. You just have to clear the local tasks cache tags in order to achieve that.
Comment #3
cosmicdreams CreditAttribution: cosmicdreams commented@dawehner are you telling me that after I create a new display mode I HAVE TO clear the cache in order to use it?
Comment #4
dawehnerNo YOU haven't but the code should clear these cache tags.
Comment #5
cosmicdreams CreditAttribution: cosmicdreams commentedOK, then this is a bug. Will change title to better target the problem.
Comment #6
Berdirfield_ui.module already has field_ui_view_mode_presave(), and field_ui_view_mode_delete().
I think those hooks are actually dead right now because the entity type is now called entity_view_mode. But that's the place where we should clear whatever cache we have.
It's probably not just the local task cache (clearCachedDefinitions() on the local task plugin manager) but also the view mode caches in EntityManager (clearCachedFieldDefinitions() there I think as views modes are cached with the entity_field_info tag).
I also think we need this for form modes, so we should add the same logic there (hook_entity_form_mode_presave() and delete).
Comment #7
BerdirAlso, I'd say this is just a bug, no need for prefixing, regressions have no special privileges (anymore).
Comment #8
swentel CreditAttribution: swentel commentedMoving to field ui module
Comment #9
swentel CreditAttribution: swentel commentedThe cache clear needs to happen when you enable or disable a view mode on the default screen of manage display.
Also when deleting a view/form mode we need to clean up the entity displays as well.
Comment #10
swentel CreditAttribution: swentel commentedSo scratch my comment, berdir was right, the hooks needed to be renamed.
I'd say we remove the entity displays on removing a mode in another issue.
Comment #11
aspilicious CreditAttribution: aspilicious commentedDon't we need a test for this?
Comment #12
swentel CreditAttribution: swentel commentedworking on it
Comment #13
swentel CreditAttribution: swentel commentedNow with tests
Comment #15
aspilicious CreditAttribution: aspilicious commentedComment #16
catchShould this really be in presave or insert/update?
Comment #17
swentel CreditAttribution: swentel commented@catch If we use insert/update we'll have two more hook implementations, so we'll end up with 6 instead of 4. The other difference would be that insert/update runs after the entity is saved, but as far as I can see, this has no impact - I think.
Comment #20
swentel CreditAttribution: swentel commentedComment #21
swentel CreditAttribution: swentel commentedBetter patch
Comment #23
BerdirLooks good to me, easy fix that is confusing users quite a bit, as seen by multiple Drupal answers questions.
Comment #24
alexpottThis issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed 0b5587b and pushed to 8.0.x. Thanks!