Problem/Motivation
Create a paragraph type with an ER field and use IEF as form display. Add these new type to a paragraphs field in your node. Paragraphs have to be in "preview" mode.
Create a node with one paragraph.
Save the node.
Edit the node.
Add a second paragraph.
Move the second paragraph to top.
Save and you will get the following error:
For the IEF complex widget:
TypeError: Argument 1 passed to Drupal\Core\Field\WidgetBase::massageFormValues() must be of the type array, null given, called in /Users/christianfritsch/Sites/devdesktop/drupal-8.1.9/modules/inline_entity_form/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php on line 576 in Drupal\Core\Field\WidgetBase->massageFormValues() (line 505 of drupal-8.1.9/core/lib/Drupal/Core/Field/WidgetBase.php).
For the IEF Simple widget:
TypeError: Argument 4 passed to Drupal\Core\Field\WidgetBase::setWidgetState() must be of the type array, null given, called in /Users/christianfritsch/Sites/devdesktop/drupal-8.1.9/modules/inline_entity_form/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php on line 173 in Drupal\Core\Field\WidgetBase::setWidgetState() (line 459 of drupal-8.1.9/core/lib/Drupal/Core/Field/WidgetBase.php).
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | saving_problem_in-2804377-2.patch | 1.28 KB | chr.fritsch |
| #10 | saving_problem_in-2804377-10.patch | 3.79 KB | chr.fritsch |
| #10 | saving_problem_in-2804377-10-TEST-ONLY.patch | 2.94 KB | chr.fritsch |
Comments
Comment #2
chr.fritschI added a patch, that fixed that bug
Comment #3
chr.fritschComment #4
hnln commentedHad the same problem, patch solves it.
Comment #5
hoemmawelt commentedSame here, patch solves the problem. Thx!
Comment #6
miro_dietikerMakes sense.
I understand that people combine these things. But if we want to officially support it, we need a dedicated class.
We need a test_dependency patch first to make testbot support Para + IEF tests.
Then please provide a new class with two methods, one for simple and complex case.
And a short explanation why Paragraphs inside IEF make sense would also be nice. ;-)
Comment #7
hnln commentedAs for use case, I use a custom entity 'paragraph_settings' that is used by every entity type. It contains some setting fields (title, width, background, ...) that are used by every paragraph type. Using a separate entity is less maintenance then adding these fields individually to each paragraph type. Since each setting entity has a 1-1 relation with a paragraph, the normal entity reference widgets (autocomplete, entity browser, ...) are no use and ief is perfect, the settings fields are directly embedded in the paragraph.
Comment #8
jmuzz commentedThis is a followup to the related issue in a way. As I understand it this is not about putting paragraph's in IEF it's about putting an ER field using IEF inside a paragraph.
The test dependency and some basic tests for IEF exist already and could be continued to test this case.
I tried the steps in the issue summary with the latest dev version of the modules and Drupal 8.3.x but I wasn't able to duplicate the error. I only tried the simple widget.
Can anybody duplicate this using the latest versions?
Comment #9
miro_dietikerAh yeah, IEF inside Paragraphs make perfect sense to deal with references to existing separate entities with option to create a new one.
So if jmuzz can't reproduce, we need more info.
And even if this issue self-resolves, i'm willing to add an IEF test example to make sure things work as expected when combined together.
Comment #10
chr.fritschI've added a test to illustrate the problem a bit better
Comment #13
jmuzz commentedNot sure why I couldn't make the error happen when I tried it before. I manually followed along with what the test did and saw it. The patch causes the node to be saved correctly instead of "The website experienced an error"
Comment #14
chr.fritsch@miro_dietiker: Is here something else to do before you can push it?
Comment #15
micbar commentedI can confirm that this patch solves the problem.
Could't save paragraphs in preview mode. I have a paragraph type with a media entity (Audio).
Comment #16
pilulu commentedThe patch in #10 worked for me
Thanks
Comment #18
miro_dietikerCommitted, thx for the hard work and clean test coverage!
Comment #20
markconroy commentedHi Folks,
I'm presuming this has been applied to the dev branch. Do you have any idea when you might make a new 8.x-1.1 release of paragraphs module to have this available in a stable release?
Thanks.
Comment #21
brooke_heaton commentedThis is an issue again. Happening to me on Paragraphs 8.x-1.11.