- Issue created by @SocialNicheGuru
- π©πͺGermany hctom
Hi @SocialNicheGuru, thanks for your request. Can you please outline the use case for this a little more? Because in my understanding, the
default
view mode should always be treated as a fallback view mode that is used, if there is no specific view mode configured or a requested view mode does not exist anymore.Another option might be to create a custom "default" view mode, that you can use in all view mode switch fields to switch to a generic representation of an entity, while preserving the system's
default
view mode fallback functionality. - πΊπΈUnited States callinmullaney
@hctom I think I'm having a similar issue to the one described above. The selected view modes are not available on the field edit page. There is a `View modes allowed to switch to` field that is set to required but there are no options to select any and the default value select list is empty and only says `-no-change-`.
Using the most recent version of Drupal 9.5.x and the latest version of the module you should be able to do the following to reproduce.
1. Create a paragraph with 3 view modes. default, custom_a, custom_b and make sure they are enabled for said paragraph.
2. Add the view_mode_switch field to the paragraph and select either all view modes or just the custom ones on the field_settings page.
3. On the following field_edit page the previously selected view_modes are not available in the default field value section. Attempting to save the field_settings page results in a drupal message of " View modes allowed to switch to field is required. " - π©πͺGermany hctom
@callinmullaney thank you for your detailed issue description. If I understand you right, you are enabling all your view modes in the field storage settings form and do not see them in the field instance settings anymore, right?!
I guess I have to rework the UI texts a little to make them better understandable ;) But I'll try to (hopefully) clarify this a little more with an example:
Let's assume, you have a paragraph type "Image + Text" and you want to be able to display this paragraph type in 3 different variants: Image above text, image to the left of the text, image to the right of the text. All these three custom view modes are created and their corresponding displays are configured for the "Image + Text" paragraph type.
In order to be able to switch to those view modes, you then add the view mode switch field to the paragraph type.
In the field storage settings, you only configure the "View modes to switch", meaning the view modes that may be switched by the field, when requested to render. In this example, this may only be "Default" (or whatever view mode you are using to render paragraphs in your embedding content). Maybe you also want to switch the "Preview" view mode with this field as well (e.g. to have a live preview of the view mode switch in the backend). If so, check the "Preview" view mode, too - the view mode switch field will then handle switching display output whenever the "Default" or the "Preview" view modes are requested to render (of course only if an editor has set a view mode to switch to). All configured view modes in the field storage settings form are now treated as ORIGIN view modes. Just think about them as a switchable placeholder slot which may even provide a default display variant, if the view mode switch field is not set to be required.
In the field instance settings you have to configure the "Views modes to switch to", meaning the target view modes that the view mode switch field switches the display output to, if selected by an editor. In this example, those would be "Image above text", "Image to the left of the text" and "Image to the right of the text". All configured view modes in the field instance settings form are now treated as TARGET view modes. With this approach, the view mode switch field should be required, so the "- No change -" option is not available, which would lead to rendering the paragraph in the requested ORIGIN view mode ("Default", "Preview").
The "Default" view mode is never available in the field instance settings form as TARGET view mode, because it should always be treated as the fallback for any requested view mode that may not be available anymore. Additionally, in the field settings you are not able to select any view modes that you already configured as ORIGIN view modes for this field. This is because there is no reason to allow to e.g. switch a "Custom A" ORIGIN view mode to a "Custom A" TARGET view mode because they are already the same.
The ORIGIN and TARGET view modes are configured separately, so you are able to reuse a field switching a specific set of ORIGIN view modes (field storage config, which is always global for a field everywhere it is used), but use different TARGET view modes (field instance config) per implementing bundle.
Does this help or even solve your problems? Or did I get you completely wrong? ;)
- π©πͺGermany hctom
Hi @SocialNicheGuru and/or @callinmullaney, do you have any feedback for me? Otherwise I will close this issue, because without feedback it is impossible to work on this potential issue.
- Status changed to Closed: works as designed
over 1 year ago 9:37am 12 September 2023