Problem/Motivation
Any Drupal form element that has #group set (via contrib field_group module, core's own
vertical-tabs grouping in NodeForm/MediaForm/BlockForm, or core
field_layout module) will render as an empty string, with no error or
warning, if it is extracted from the form array and rendered on its own as
the content of an `AjaxResponse` command (`ReplaceCommand`, `InsertCommand`,
`HtmlCommand`, ...), instead of being rendered together with the rest of the
form.
Currently this affects the media library widget from core.
Steps to reproduce
Probably this can be reproduced by adding media library widget to a group created by the field_layout module.
Proposed resolution
To be figured out but this is more to document for now. Quite edgy so may not ever have a solution.
The workaround is adding a unset($element['#group']) on the renderable prior to wrapping in an AJAX command in a form AJAX callback (As core does it in https://git.drupalcode.org/project/drupal/-/blob/main/core/lib/Drupal/Co..., Media library doesn't do it in https://git.drupalcode.org/project/drupal/-/blob/main/core/modules/media...)
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3617783
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 #4
jeffmattsonComment #5
smustgrave commentedSeems like some research was needed first right?