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
If a form organizes elements in groups (vertical tabs) using #group AJAX functionality via #ajax may break. If one tries to do an AJAX update of an element inside #group it gets simply wiped out.
The reason is \Drupal\Core\Render\Element\RenderElement::preRenderGroup(), which marks element as #printed and prevents it from actually rendering.
Proposed resolution
Let's make \Drupal\Core\Form\FormAjaxResponseBuilder::buildResponse() aware of this and prevent preRenderGroup() from being run before sending element to the renderer.
Comment | File | Size | Author |
---|---|---|---|
#15 | 2567091_15.patch | 4.8 KB | slashrsm |
#15 | interdiff.txt | 1.85 KB | slashrsm |
#13 | interdiff.txt | 1.08 KB | slashrsm |
#13 | 2567091_13.patch | 4.04 KB | slashrsm |
#8 | 2567091_8_TEST_ONLY.patch | 3.03 KB | slashrsm |
Comments
Comment #2
slashrsm CreditAttribution: slashrsm at Examiner.com commentedAttached patch tries to fix this issue in a general way.
Fix addresses the issue only for the cases where parts of form are returned. Ajax callbacks that return own ajax commands are not covered and I am not sure how to solve that efficiently.
Comment #3
slashrsm CreditAttribution: slashrsm at Examiner.com commentedRephrased comment a bit.
Comment #4
marcingy CreditAttribution: marcingy at Examiner.com commentedLooks good
Comment #5
jibranCan we write some tests for this? Added a tag for core contributors.
Comment #6
catchYes this needs test coverage.
Comment #7
alexpottThanks for tagging this for rc target triage! To have committers consider it for inclusion in RC, we should add a statement to the issue summary of why we need to make this change during RC, including what happens if we do not make the change and what any disruptions from it are. We can add a section
<h3>Why this should be an RC target</h3>
to the summary.Comment #8
slashrsm CreditAttribution: slashrsm at Examiner.com commentedWe are past RC. 8.1.x material I assume.
Added test.
Comment #10
slashrsm CreditAttribution: slashrsm at Examiner.com commentedExpected fail.
Comment #11
Primsi CreditAttribution: Primsi at Examiner.com for Examiner.com commentedTest looks ok
Comment #12
swentel CreditAttribution: swentel commentedThe comment confuses me a little. Could probably use a comma after 'it'. The 3rd line sounds weird to me, it feels like something is missing after/between 'as when' ? Won't block this as I don't have a better proposal for now.
Also, this is a straight bug fix, this can go in 8.0.x as well I guess no ?
Comment #13
slashrsm CreditAttribution: slashrsm at Examiner.com commentedBetter? Let's see what maintainers say about 8.0.x vs 8.1.x.
Comment #14
catchDo we need to be concerned about the case where #ajax is set on a parent element, and #group is set on a child? Patch doesn't look like it would cover that if so. I'm assuming things are only broken when it's the same level, but just in case, and doubt we have test coverage for that.
Comment #15
slashrsm CreditAttribution: slashrsm at Examiner.com commentedSomething along those lines?
Comment #16
Primsi CreditAttribution: Primsi at Examiner.com for Examiner.com commentedComments addressed, I would say RTBC again.
Comment #17
catchThanks for the extra test coverage. Committed/pushed to 8.1.x and cherry-picked to 8.0.x. Thanks!