Problem/Motivation

When a dependent field is placed inside a field group, changing the parent field replaces the dependent field's wrapper into an empty string, so the field disappears from the form.

ViewsSelection::updateDependentField() renders the element manually with $renderer->render($form_field). Elements that belong to a group carry #group, and RenderElementBase::preRenderGroup() defers their rendering to the group container — a direct render returns an empty string. Core handles this in ajax callbacks by unsetting #group before rendering, see \Drupal\Core\Form\FormAjaxResponseBuilder::buildResponse().

Proposed resolution

Unset #group on the element before rendering it for the ReplaceCommand, mirroring core's FormAjaxResponseBuilder.

Command icon 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

pcambra created an issue. See original summary.

pcambra’s picture

Status: Active » Needs review

  • pcambra committed 7b1f5586 on 1.x
    Issue #3609028: Dependent field is replaced with empty markup when...
pcambra’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.