Problem/Motivation

I can choose any viewmode - but paragraph_view_mode_entity_view_mode_alter() will not change the viewmode.

Proposed resolution

These 2 lines cannot work (in my opinion):

  $field_name = StorageManagerInterface::FIELD_NAME;
  if (!$entity->hasField($field_name) || $view_mode === ViewModeInterface::PREVIEW) {

because $field_name is this constant: "paragraph_view_mode". You must search for a field with fieldDefinition.field_type = "paragraph_view_mode" ...

Comments

kle created an issue. See original summary.

sayco’s picture

This module provides a field type that is true, but the module ensures that you'll have only a single field of this type (because having multiple is pointless).
That's why it is defined in the code and that's why you should enable it exactly how it was instructed in the README.md:

https://git.drupalcode.org/project/paragraph_view_mode/-/blob/2.x/README...

Please let me know if this solves your issue.

sayco’s picture

Status: Active » Closed (works as designed)