I have a content type with several fields including paragraph fields. I have a sidebar region and have created a simple view which creates a block and displays the current node and for the format I have selected rendered entity and for the display mode I have selected "sidebar first" which is one of the display modes I have enabled for this content type.
On manage display for "sidebar first" I have two fields, an entity reference field and a paragraphs field. On both I have enabled display suite and field templates and have chosen the "expert" field template in order to change the markup / class for the label and output everything else clean.
The entity reference field is outputting as expected but the expert field template is being ignored on the paragraphs field and it being output using the Drupal default.
Comment | File | Size | Author |
---|---|---|---|
#3 | paragraphs-fix-formatter-view-mode-3044164-03-D7.patch | 1.39 KB | Pryrios |
|
Comments
Comment #2
Pryrios CreditAttribution: Pryrios commentedI think I may have found the issue regarding this.
On Display Suite Extras, when doing the preprocess on ds_extras_preprocess_field the host entity is checked to see if there is a DS layout, otherwise DS extras cannot be applied. Parameters are the entity type of the host entity, bundle and view mode. The view mode passed onto that check is the one on the element array, along with the entity type and bundle also present on that element.
When configuring the formatter for a paragraph field on Manage Display, a view mode is selected. Then on paragraphs_field_formatter_view when building the $element variable, the view mode assigned is the one from the configuration, but I think this is wrong. It should assign the view mode of the parent entity.
Clarification: This happens to me on a multivalue Paragraph field. I have not tested a single value field.
Comment #3
Pryrios CreditAttribution: Pryrios as a volunteer commentedProposed fix. This should keep the classes on paragraphs fields while not breaking the DS theming of extras. I don't think the #view_mode is being used anywhere else outside the preprocess so this should be safe.
Comment #4
Pryrios CreditAttribution: Pryrios as a volunteer commentedComment #5
hanoiiVery interesting this is almost the same patch as a 3 years old issue #2638780: Conflict with Field API #view_mode. See the maintainer response there. I am trying to figure if there's secondary issue or not.
I was also tracking odd issues with view modes, can you maybe also try #3066229: View mode on the paragraph field is not respected if you can.
Comment #6
hanoiiFrom #2638780-4: Conflict with Field API #view_mode:
I tried reviewing this, and I think it just works properly with and without nested entities, and found no issues.
Why "needs work" @Pryrios?
Comment #7
Pryrios CreditAttribution: Pryrios as a volunteer commentedFirst of all it probably needs automated tests to verify it is working properly.
Then, the fix is very simple, so I may be breaking something, but seeing that it passed current tests, maybe not.
I will gladly write tests for this patch, but I am not very fluent at writing them so it may take me a while. If anyone wants to take a stab at it meanwhile, it is welcome.
Comment #9
jstollerPatch committed to dev.