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
- Install and enable paragraph_view_mode 3.1.0 or greater.
- Create a new paragraph type.
- Add an image field to the paragraph type.
- Enable Paragraph view mode field on the paragraph type.
- Create a Paragraph field on a content type and configure it to support the paragraph type.
- Create a new node of the content type.
- Add an instance of the paragraph type.
- 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.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 20240201-paragraph_view_mode-fix-file-field--issue-3357506.patch | 1.1 KB | paul dudink |
Comments
Comment #2
wellsComment #3
alexxandre commented@wells same problem here ; your workaround works, thank you.
Comment #5
sayco commentedI'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.
Comment #7
sayco commentedI 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
Comment #8
sayco commentedI 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.
Comment #9
paul dudink commentedWe 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?
Comment #10
paul dudink commentedNever mind my previous comment. Looking at your commits I created a quick-fix patch for people who encounter this issue.
Comment #11
sayco commentedThanks for adding the patch. I just created a new stable release which includes this change, so you can upgrade your project version.