Problem/Motivation
In #2346893: Duplicate AJAX wrapper around a file field we discovered that with #render_children the render system duplicates some rendering, resulting in #prefix and #suffix being rendered twice. That duplication was fixed there. We still need to investigate whether this happens for other properties like #post_render.
In #2190333: Make #group FAPI / render feature work on all form/render #types out of the box, another case on clean main was found: a textfield assigned to a datetime element using #group is rendered twice. The datetime template renders the element again to output its children, causing preRenderGroup() to add the group members again. This does not require #2190333: Make #group FAPI / render feature work on all form/render #types out of the box to be applied, but if applied, more elements will be affected (datelist, managed_file).
Also there are concerns about:
- Resolve ongoing discussion of related changes to metadata.
- Decide whether or not to bubble up the cache and assets here - see #2346893-185: Duplicate AJAX wrapper around a file field
Proposed resolution
Add regression coverage for repeated rendering, starting with the grouped-element case, and fix the duplication. The exact fix still needs to be determined.
Remaining tasks
- Review the added
FormElementGroupingTest, which currently fails because the grouped textfield appears twice instead of once. - Fix the duplicate rendering of group members.
- Investigate the remaining questions about other callbacks, metadata and cache/asset bubbling. The grouped-element test does not cover these.
User interface changes
API changes
Data model changes
Issue fork drupal-2926030
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
alexpottComment #3
alexpottComment #15
smustgrave commentedThank you for creating this issue to improve Drupal.
We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.
Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
Thanks!
Comment #19
berliner commentedWhile working on #2190333: Make #group FAPI / render feature work on all form/render #types out of the box I found a case where repeated rendering still causes duplication in current core, without that MR applied. I added a test case exposing this with a
textfieldassigned to adatetimeelement using#group.For the duplication to occur, it requires:
#group.preRenderGroup()to add the members again.If #2190333: Make #group FAPI / render feature work on all form/render #types out of the box gets merged, this would therefore also affect
datelistandmanaged_filewhen used as group targets. I reproduced this locally by explicitly enabling their grouping callbacks.Comment #20
berliner commentedComment #21
berliner commentedAdded the smallest fix I could think of for the duplicated rendering of group members. Changing to "Needs review" to hopefully get some feedback on the direction.
Comment #22
smustgrave commentedTagging for summary update when a solution is determined.
Thanks.