When I’m trying to edit a page with inline entity form inside a paragraph in a “Closed” form state I get error:
TypeError: Argument 1 passed to Drupal\Core\Field\WidgetBase::massageFormValues() must be of the type array, null given, called in /var/www/drupalvm/docroot/modules/contrib/inline_entity_form/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php on line 577 in Drupal\Core\Field\WidgetBase->massageFormValues() (line 505 of core/lib/Drupal/Core/Field/WidgetBase.php).
| Comment | File | Size | Author |
|---|---|---|---|
| #24 | stack trace.txt | 7.59 KB | thomwilhelm |
| #4 | compatibility-with-paragraphs-module-2787969-4.patch | 765 bytes | dima.iluschenko |
| #3 | compatibility-with-paragraphs-module-2787969-3.patch | 772 bytes | reekris |
| #2 | compatibility-with-paragraphs-module-2787969-2.patch | 2.95 KB | dima.iluschenko |
Comments
Comment #2
dima.iluschenkoUploaded quick patch.
Comment #3
reekris commentedI have the the same issue, however your patch seems to have changes to code indentation. Here is a patch that just returns if
$widget_state == null. This seems to fix the issue for me.Comment #4
dima.iluschenkoright :), it's better for reading. small change for drupal standard ;)
Comment #5
reekris commentedAh, thanks :)
Comment #6
reekris commentedComment #7
dawehner@reekris
I'm wondering whether you understand exactly why this happens? If yes, it would be really helpful for @bojanz to know why, so reviewing the patch is much easier.
Hiding some error though is often not the best idea.
Comment #8
jlbellidoSubscribed, I agree that the current patch is not a solution and we need to know what the real problem is.
Comment #9
ndeet commentedComment #10
dawehnerLet's indicate with tests that we have actual problems. Yeah just guessing around has potentially more unforeseen consequences.
Comment #11
dawehnerComment #12
n8tronI was getting the same error(s) while nesting multiple paragraphs with IEF. "Update Node/Create Node" button threw this error(s) and failed. When I click "Save and Keep Published" the errors are a follows.
Warning: Invalid argument supplied for foreach() in inline_entity_form/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php on line 558
Warning: uasort() expects parameter 1 to be array, null given in inline_entity_form/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php on line 578
Catchable fatal error: Argument 1 passed to Drupal\Core\Field\WidgetBase::massageFormValues() must be of the type array, null given, called in inline_entity_form/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php on line 580 and defined in core/lib/Drupal/Core/Field/WidgetBase.php on line 505
This patch seems to have corrected the issue. I'm still looking into things...
Comment #13
melvinlouwerse commentedI have tried to figure this one out to see where it goes wrong
Fist of all this only happens with the paragraphs module when the form display is set to preview.
It also only happens when you are editing a node that has at least 1 paragraph with an (complex) inline entity form prior saved.
When you save your node (without changing anything) it will give this fatal error.
If you just open the paragraph to edit it and then close it again without saving anything you will be able to save.
The problem seems to be because the paragraph module in just preview mode does not render the inline entity form until the edit button is pushed.
Because the form is not rendered this following code src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php line 190 is not executed
So when on save the paragraphs module asks in paragraphs/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php extractFormValues (trough widgetbase /core/lib/Drupal/Core/Field/WidgetBase.php line 370 ) to run massageFormValues it will arrive on
src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php on line 551
This will create a sha1 hash to find the inline form in our form state.
But since it was never created we receive NULL the rest of the code does not check or warn that the inline form was not found. We end up on line 576 with an empty $value variable causing the fatal error.
In this case the patch would work because an empty widget_state in this case is a valid state as we never had that inline form we did not change it so we dont need to do anything with its values.
Not sure if it would potentially break other stuff though.
I hope this helps
Comment #14
fathershawnI have this issue, with IEF in complex mode, but Paragraphs is set to closed. I'm working to investigate further but posting here to save someone re-configuring their Paragraph form displays to try to work around.
Comment #15
melvinlouwerse commentedClosed has actually the same issue, No form is loaded initially, You need to click the edit button to load in the form.
So this is true for closed as well.
Comment #16
chr.fritschApply the latest patch from #2804377: Saving problem in preview mode with IEF items to your paragraphs module, should fix the issue
Comment #17
geek-merlinFixed as of #16.
Comment #18
geek-merlinThis was reported again it seems.
Comment #19
damien laguerre commentedI encountered this issue and it's due to the way to generate the ids.
It has changed:
Before:
$this->setIefId(sha1(implode('-', $parents)));Now:
$this->setIefId(Crypt::hashBase64(implode('-', $parents)));If you have extends/write a custom widget, make attention to use the new encoding.
Comment #20
geek-merlinComment #21
geek-merlinIEF rc9 is out and has some fixes for nested forms. Can this still be reproduced?
Comment #22
Drupalengue commentedYes, this still happens. I got this error on RC9 on a complex paragraphs + IEF form:
TypeError: Argument 2 passed to Drupal\Component\Utility\NestedArray::getValue() must be of the type array, null given, called in /site.com/html/modules/contrib/paragraphs/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php on line 1309 in Drupal\Component\Utility\NestedArray::getValue() (line 69 of /site.com/html/core/lib/Drupal/Component/Utility/NestedArray.php)when adding more than 1 Entity with IEF inside a paragraph and then saving the form. If more details are needed I can try on a fresh install and try to write down the steps. This happens on a complex form with multiple paragraphs (some have 3 levels deep) and 1 Entity added to them using IEF. Form displays are set to simple and with Edit mode preview->open in most cases.
Comment #23
socialnicheguru commentedComment #24
thomwilhelm commentedJust ran into this when upgrading to 1.0-rc10 from 1.0-rc9.
TypeError: Argument 2 passed to Drupal\Component\Utility\NestedArray::getValue() must be of the type array, null given, called in /mnt/www/html/rfepaasjfmsen3/docroot/modules/contrib/paragraphs/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php on line 1306 in Drupal\Component\Utility\NestedArray::getValue() (line 69 of /mnt/www/html/rfepaasjfmsen3/docroot/core/lib/Drupal/Component/Utility/NestedArray.php)
Attaching a full stack trace. Reverting to 1.0-rc9 fixed this issue!
Comment #25
berdirNote: I didn't investigate yet, but our IEF integration test in the paragraphs module is failing with a PHP notice, which might be related to that (Notice: Undefined index: array_parents: https://www.drupal.org/pift-ci-job/2332366).
Comment #26
dahousecat commentedI also have this issue.
Can confirm reverting to 1.0-rc9 fixed the problem.