- Issue created by @dalemoore
- πΊπΈUnited States dalemoore
So I just did a little testing with Twig debugging enabled.
If I only use this module, and I inspect the source code, the Twig suggestions for the node.html.twig never change on the Layout Builder-enabled content type. No matter what I select in this module's field dropdown, I always get this:
<!-- FILE NAME SUGGESTIONS: * node--281905--full.html.twig * node--281905.html.twig * node--page--full.html.twig * node--page.html.twig * node--full.html.twig x node.html.twig -->
If I instead enable Display Suite's view mode switcher and change it to a different view mode, the Twig suggestions are updated to the new view mode's name.
<!-- FILE NAME SUGGESTIONS: * node--281905--standard.html.twig * node--281905.html.twig * node--page--standard.html.twig * node--page.html.twig * node--standard.html.twig x node.html.twig -->
- π©πͺGermany hctom
Thanks for the report. In order to track down this issue, I need some more information from you:
- How is your VMS field configured? Especially: What are the
View modes to switch
inField storage
? Is it enabled forFull
and/orDefault
It would be nice, if you could provide this information, so I can try to reproduce this potential issue.
Thanks!
- How is your VMS field configured? Especially: What are the
- πΊπΈUnited States dalemoore
Thanks!
Here is a detailed description. This is on the standard profile 'page' content type.
Manage fields
- I've added a view mode switch field labeled "View mode" with machine name "field_view_mode".
- Under field storage, "view modes to switch", the only view mode selected is "Default". Full content is not checked because if I check it it removes it from "View modes allowed to switch to".
- The field is set to "required"
- Under "View modes allowed to switch to", I have selected:
- Full content
- Standard
- Teaser
- Under default value, I have it set to "Full content".
That's it for the field setup.
Manage form display
The field is just setup with the defaults here.
Manage display
- In custom display settings, I have enabled "Full content", "Standard", and "Teaser" view modes (Standard is a view mode I manually created).
- I have "Use Layout Builder" and "Allow each content item to have its layout customized" enabled on the Default view mode.
- On the Standard view mode, I don't have anything Layout Builder enabled, just the normal field/label/format view.
- π©πͺGermany hctom
Thanks for the details - I think, I know what the problem is: You are only switching the
default
view mode, but you are accessing the entity infull
view mode.So you have to check
full
view mode (because you want to switch away from that one) under "View modes to switch" in field storage config instead of enabling it under "View modes allowed to switch to".
Additionally your field should be optional - if no switch is selected later, thefull
view mode (with layout builder and potential overrides enabled) is displayed, ifstandard
is selected, that view mode will be used instead. I have some of these setups running without problems.Please let me know, if that fixes the issue for you.
- πΊπΈUnited States dalemoore
Thanks! Yes, that fixes it!
I guess I didn't think of that because I want the user to be able to select from options that are labeled meaningfully, so I wanted "Full content" or "Layout Builder" (really the full view mode, which is the only one Layout Builder overrides work with currently β¨ Consider supporting Layout Builder Overrides for other view modes Needs work ) to be an option they can select. Hence the making it required and wanting the "Full content" option to be selectable under "View modes allowed to switch to", so there would be no option "- No change -" which I felt was confusing. Could I perhaps configure what that "no change" option says on a per-field basis, even if in code? Maybe it could be added in the form display widget?
- Status changed to Closed: works as designed
8 months ago 8:40pm 18 April 2024 - π©πͺGermany hctom
You are welcome... and this is actually really something I was already thinking about, to allow setting custom labels for the field options. I'll give this a try soon, when I have some spare time again.
In the meantime you may alter the displayed label of the field's empty value by implementing a corresponding field widget form alter hook.
For now, I will close this issue as "works as designed" and I will start on a follow up for the custom labels soon.