Problem/Motivation

Steps to reproduce:

  • Edit node
  • Add a 'paragraph library' paragraph entity to a paragraph entity reference revision field.
  • Save node
  • View the node edit form

Result:

  • Presented with: Notice: Undefined index: field_reusable_paragraph in paragraphs_library_preprocess_paragraph() (line 145 of modules/contrib/paragraphs/modules/paragraphs_library/paragraphs_library.module). and a stack-trace

Comments

lukus created an issue. See original summary.

peterhebert’s picture

I can confirm this issue is happening, Drupal 8.9.1. Looks like the view mode is directly under 'elements':

$variables['elements']['field_reusable_paragraph'][0]['#view_mode']

should be:

$variables['elements']['#view_mode']
peterhebert’s picture

StatusFileSize
new895 bytes

adding patch for solution mentioned in #2

berdir’s picture

That's not necessarily the same thing. The current view mode is the one configured on the entity reference field and is the correct one to use. The one on the main element is the view mode on the paragraph, that might or might not be the same.

primsi’s picture

Status: Active » Needs review
StatusFileSize
new1.18 KB
new951 bytes

Patch for the approach in #4.

berdir’s picture

Status: Needs review » Fixed

Thanks, I think just not doing anything if the expected data is not there is the right approach. Could also happen if the field is configured to use a different widget like label, but I don't see how we could do anything useful then here if the data doesn't match our expectation.

Committed.

  • Berdir committed 42842d5 on 8.x-1.x authored by Primsi
    Issue #3145886 by Primsi, peterhebert: Notice: Undefined index:...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

spacerabbit’s picture

Thanks! That worked for me on paragraphs 8.x.1.12