Problem/Motivation

When using the "bind with the form mode" option introduced in #3150153: Bind paragraph view mode with form mode on a paragraph type with an image field it is not possible to upload an image due to an AJAX error.

Steps to reproduce

  1. Install and enable paragraph_view_mode 3.1.0 or greater.
  2. Create a new paragraph type.
  3. Add an image field to the paragraph type.
  4. Enable Paragraph view mode field on the paragraph type.
  5. Create a Paragraph field on a content type and configure it to support the paragraph type.
  6. Create a new node of the content type.
  7. Add an instance of the paragraph type.
  8. Attempt to upload an image to the image field.
Expected result

Form updates with the newly uploaded image.

Actual result

An AJAX error is logged in the web console and the image widget does not properly update. The site log will have an error: Exception: Serialization of 'Symfony\Component\HttpFoundation\File\UploadedFile' is not allowed in serialize() (line 14 of /app/web/core/lib/Drupal/Component/Serialization/PhpSerialize.php).

Workaround

To work around the issue one can disable the "bind with the form mode" option in the form display settings for each affected Paragraph view mode widget.

Proposed resolution

Unclear but there are a couple of other issues that have addressed a similar error message. Recording here in case they can help troubleshoot this issue:

#3328986: Files cannot be attached to the form
#2974237: Serialization exception when trying to edit a file/image field
#2793621: Upload files when adding content to group don't work well

Remaining tasks

Determine how to resolve the issue and create a patch/MR.

Comments

wells created an issue. See original summary.

wells’s picture

Issue summary: View changes
alexxandre’s picture

@wells same problem here ; your workaround works, thank you.

  • sayco committed 9e867003 on 3.x
    Issue #3357506: Bind with the form mode breaks image uploading with...
sayco’s picture

Status: Active » Needs review

I've merged a change to the dev branch. It seems like it will fix the issue, but it would be great if someone could also test it anyway.

  • sayco committed 279e01ce on 3.x
    Issue #3357506 by sayco: Remove disabling cache, change the ajax...
sayco’s picture

I had to apply yet another fix (and remove the previous change) because I broke more stuff than I fixed :D
It seems now that the ajax callback is working a expected

sayco’s picture

Status: Needs review » Fixed

I did some testing and it seems like the issue is solved. If anyone falls into trouble again, we have a quick workaround but a better solution must be found.

paul dudink’s picture

We have the same issue. So what is the fix at this moment? Can we safely checkout the dev branch or is there a patch available?

paul dudink’s picture

Never mind my previous comment. Looking at your commits I created a quick-fix patch for people who encounter this issue.

sayco’s picture

Thanks for adding the patch. I just created a new stable release which includes this change, so you can upgrade your project version.

Status: Fixed » Closed (fixed)

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