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
#2032649: Rework inline form submission improved submission handling in D7 version. We should forward-port that patch to D8.
Proposed resolution
Forward port patch from #2032649: Rework inline form submission. Remove hack that we added in #2609020: Unable to reedit entity in a single request.
Comment | File | Size | Author |
---|---|---|---|
#11 | interdiff.txt | 2.52 KB | tedbow |
#11 | ief-forward_port_submission-2612720-11.patch | 13.47 KB | tedbow |
| |||
#9 | interdiff.txt | 2.59 KB | tedbow |
#9 | ief-forward_port_submission-2612720-9.patch | 18.3 KB | tedbow |
| |||
#7 | interdiff.txt | 8.74 KB | slashrsm |
Comments
Comment #2
bojanz CreditAttribution: bojanz at Centarro commentedThis needs to be our biggest IEF priority, otherwise we'll need to keep adding band-aids for bugs the D7 version doesn't have.
Comment #3
tedbowI just taken a good look at http://cgit.drupalcode.org/inline_entity_form/diff/?id=a754ba7
Which the commit for the referenced issue.
It looks to me like most if not all of the logic for that patch is already in 8.x-1.x.
Comment #4
tedbowOk uploading a patch that fixes some remaining submissions.
I wasn't sure if I should post it here or #2626970: Add testcase for nested inline entity form
This patch does get all of those test passing up to this point on the issue:
https://www.drupal.org/node/2626970#comment-10826306
I have upload this patch I will add another comment explaining some of the changes
Comment #5
tedbowCreate addSubmitCallBacks because this same two function were being added in multiple places in this manner.
I also added #ief_trigger as a way to know which elements should trigger IEF saves so that isSubmitRelevant could be much simplier.
Moved this function to static function on \Drupal\inline_entity_form\Element\InlineEntityForm
This could probably be done with more functions to remove code from .module file
This was not ported from D7 before. This ensures that main submit button gets the IEF callbacks.
Relying on AJAX callbacks to do this doesn't seem to work.
Ensuring that parent form buttons are marked as IEF triggers.
Because of #ief_trigger we can remove this logic and just check if it is a trigger.
We should not actually be doing the saves or deletes until the main parent submit button is submitted(checked via #ief_submit_all)
This from my understanding that entities should only be saved with the main form.
Comment #6
mansspams CreditAttribution: mansspams at Wunder commentedThis is great! Golden star!
Comment #7
slashrsm CreditAttribution: slashrsm at Examiner.com commentedThis looks great. Just few cosmetic fixes:
- functions that were added to \Drupal\inline_entity_form\Element\InlineEntityForm are widget-specific logic and should live in widget class as such.
- Entirely removed isSubmitRelevant() and moved the check to the calling function.
Will test this patch manually a bit more, but I think we should be pretty close.
Thank you!
Comment #8
slashrsm CreditAttribution: slashrsm at Examiner.com commentedFound a bug... Steps to reproduce:
- enabled inline_entity_form_test
- make reference fields on ief_test_nested1 and ief_test_nested2 content types non-required
- navigate to /node/add/ief_test_nested1 and create all 3 levels
- save parent entity
- edit entity that was just created
- open all nested IEFs
- change something on the last level
- close (update) all IEF forms
- save parent entity
- navigate back to edit page
- open all nested IEF forms
- Expected result: changes on last level were saved and are now visible
- Actual result: Changes on last level were not saved at all
However, without this patch entity on last level won't save at all (when creating them). Taking that into consideration I think it is ok to tackle this bug in a follow-up (with test coverage and everything).
I think it makes sense to get this in asap as:
- it fixes existing bugs,
- allows us to commit #2626970: Add testcase for nested inline entity form too, which adds even more test coverage.
Comment #9
tedbowOk here is another patch that makes a small change in \Drupal\inline_entity_form\Form\EntityInlineForm::entityFormValidate to make sure validation is only run on an entityform if the submission was trigger by the current IEF element.
This will allow one of the "required" tests in #2626970: Add testcase for nested inline entity form that is currently commented out to pass.
It also fixes part of #2649710: Required nested IEF forms don't work it allows fields that are required to work but only if you submit the forms via ajax NOT leave them open.
Comment #11
tedbowOk my 8.x-1.x was behind locally
The interdiff is still against #7
Comment #13
slashrsm CreditAttribution: slashrsm at Examiner.com commentedI went ahead and committed #7. Patches #9 and #11 belong to another issue with a different scope. They were uploaded here simply because they depended on this.
Getting this in also allowed me to commit #2626970: Add testcase for nested inline entity form, which adds valuable tests. All that will help us going forward. Anyone feel free to re-open if problems with the patch are revealed.
Thank you everyone!
Will re-upload #11 to #2649710: Required nested IEF forms don't work so we can continue there.