Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
TODO
Proposed resolution
TODO
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#35 | 2626970_35.patch | 19.49 KB | slashrsm |
#33 | 2626970-33-nested-tests.patch | 19.67 KB | tedbow |
#31 | interdiff.txt | 1.99 KB | tedbow |
#31 | 2626970-31-nested-tests.patch | 19.61 KB | tedbow |
#25 | interdiff.txt | 6.87 KB | tedbow |
Comments
Comment #2
dawehnerThere we go.
Comment #3
dawehnerNot a start actually
Comment #4
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedComment #5
dawehnerWell, this nesting already doesn't work in HEAD.
Comment #7
dawehnerMaybe this works now.
Comment #8
dawehnerThere we go
Comment #9
dawehnerLet's fail
Comment #14
dawehnerSo one small thing I found, but in general,
#tree => TRUE
causes issues all over the place.Comment #16
pjcdawkins CreditAttribution: pjcdawkins commentedAs a side note which may or may not help... in the UI, I've found this behavior with nested IEFs:
1. Set up parent_entity referencing child_entity referencing grandchild_entity.
2. Open the entity form to create a new parent_entity.
3. Click "Add a new child_entity". Then "Add a new grandchild_entity". Submit both IEFs.
4. Click "Add a new child_entity" again. The reference field to grandchild_entity in this IEF should be empty. But it is already populated with the grandchild created in (3).
Comment #17
slashrsm CreditAttribution: slashrsm at Examiner.com commentedI suggest that we make this issue do what it's title says it does. Let's add a test. We have a lot of problems in submit/validation area and @bojanz thinks that we'll need to do a major refactoring anyway. Having good test coverage will be very helpful when we will be doing that.
I suggest that we open separate issue for every bug that is found. Each issue should list clear steps to reproduce and ideally a test that demonstrates the problem.
While working on this patch I identified two problems:
- #2649710: Required nested IEF forms don't work
- #2649706: Double nested IEF can't be submitted if it's parent doesn't have required fields populated
Test in this patch can easily cover them by deleting one line and/or removing another.
Comment #18
bojanz CreditAttribution: bojanz commentedSorting submit callbacks feels very dangerous. We need a comment with the reasoning, at least.
This needs a detailed docblock.
Comment #19
slashrsm CreditAttribution: slashrsm at Examiner.com commented1. It seems that this only applies to identical items in orded to decide which key to keep: http://php.net/manual/en/function.array-unique.php. I actually don't know why we added this. Hope that @dawehner remembers.
2. Added.
Comment #20
bojanz CreditAttribution: bojanz commentedIs the patch supposed to pass? Running tests locally I get:
The offending line being:
Comment #21
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedIt was passing when I worked on this few weeks ago. Currently we have failing tests in 8.x-1.x. We should fix that before with continue with this patch. Will see if I can look at it this week.
Comment #24
bojanz CreditAttribution: bojanz commentedCommitted the fixes, they were needed to make the build pass.
The actual test is still failing. vasike said something about "a problem about the button Add vs create"
Attaching the updated patch.
Comment #25
tedbow@bojanz I attached a version that split testNestedEntityCreationWithDifferentBundles into 2 tests
testNestedEntityCreationWithDifferentBundlesAjaxSubmit and testNestedEntityCreationWithDifferentBundlesNoAjaxSubmit
testNestedEntityCreationWithDifferentBundlesAjaxSubmit is the only test that fails. If the nested forms are not submitted via ajax but rather only the main node submit button then the test passes and 3 nodes are created.
I also fixed a couple places were the "second" and "third" nodes were both being referred to as the "second" node in assert messages.
I think I have better idea of what is going on now and will take another look at it tomorrow.
Comment #26
slashrsm CreditAttribution: slashrsm at Examiner.com commentedComment #29
tedbowThe patch from #25 failed for the reason I was getting locally
Basically in the case of the 2 level nested IEF form and the IEF forms are submitted before top level form is submitted and the node in first level IEF form get saved correctly but 2nd level node is not.
Comment #30
tedbowI tracked down the problem error in #29
The reason it fails is because logic errors in \Drupal\inline_entity_form\Plugin\Field\FieldWidget\InlineEntityFormBase::isSubmitRelevant
Around line #420
$field_parents and $item are both arrays so $union will also so be an array.
$union == max(count($item), count($field_parents));
will always always be false because max is going to return an integer.
It am not positive what the intention was in that code block.
On this branch: https://github.com/tedbow/inline_entity_form/tree/2626970-nested-complex
I am playing around with seeing if isSubmitRelevant is needed
I have hardcoded it to return TRUE and the only test that fails is testEntityCreation
All others pass.
Comment #31
tedbowUpdating the patch to avoid the fatal PHP by checking if the nested nodes are not NULL before call ->title().
This at leasts lets the test finish out and demonstrates that all other tests are passing.
Comment #33
tedbowRe-rolled patch against 8.x-1.x
Tests now extend InlineEntityFormTestBase from #2661192: Create InlineEntityFormTestBase
Comment #35
slashrsm CreditAttribution: slashrsm at Examiner.com commentedReroll after last few patches that were committed.
Comment #38
slashrsm CreditAttribution: slashrsm at Examiner.com commentedCommitted. Thank you everyone!