Problem/Motivation

There is an error at moment to manage form display.

Error: Call to a member function id() on null in Drupal\paragraph_view_mode\Plugin\Field\FieldWidget\ParagraphViewModeWidget->getViewModesFieldDescription() (line 229 of /var/www/html/docroot/modules/contrib/paragraph_view_mode/src/Plugin/Field/FieldWidget/ParagraphViewModeWidget.php)
CommentFileSizeAuthor
#2 3181712-2.patch2.57 KBvacho

Comments

vacho created an issue. See original summary.

vacho’s picture

StatusFileSize
new2.57 KB

This patch fixes the problem. Please review.

vacho’s picture

Status: Active » Needs review
sayco’s picture

Status: Needs review » Postponed (maintainer needs more info)

I have reviewed your patch and seems like it's not chaning anything, the request service was already there... I suppose that your patch would rather validate something in the getViewModesFieldDescription() method, because it's possible that it won't find the paragraph type in the current request.

BTW I was working fine to me, I didn't have any errors. Could be more specific of how to reproduce the error?
What are the steps? Also please give me a specific Drupal version.

vacho’s picture

The porblem happen if you go to /admin/structure/paragraphs_type/<name_for_your_paragraph>/form-display (for a paragraph that has enabled paragraph_view_mode field)

I have this problem with core 8.7.6 where the class ParagraphViewModeWidget was not run the method create(). So, at method getViewModesFieldDescription() the object can't get the $paragraphs_type

It is the reason to the patch that's adds to this class implements ContainerFactoryPluginInterface to can implement the object by create() method.

I tested now the module with core 9.0.6 and this issue not happen. So I think we need to set the core_version_requirement from ^8 || ^9 to ^8.8 || ^9 but I am unsure if the issue not happen at 8.8

Also, we can apply this patch to get compatibility with old versions. Debatable...

sayco’s picture

Thanks for more details, things become more clear to me now. It definitely seems to be the Drupal version issue. I did check with the 8.9, will verify on 8.8 tomorrow. I would rather stick to the latest or at least supported version of D core instead of keeping backward compatibility. Maybe it will be a good time to create a version 2, and add this compatibility to 1.x only

  • sayco committed 0c30929 on 8.x-1.x authored by vacho
    Issue #3181712 by vacho, sayco: Can't manage form display
    
sayco’s picture

Status: Postponed (maintainer needs more info) » Fixed

Status: Fixed » Closed (fixed)

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