Create a dialog subform API

Created on 25 January 2025, 2 days ago

Problem/Motivation

Currently modal dialog subforms are used in many places in core and contrib, for example:

  • Block layout page - placing blocks (core)
  • Views UI forms (core)
  • Layout Builder (core)
  • Media library widget (core)
  • Entity browser (contrib)

and many more..

However, every single one has its own implementation which is more of a workaround where either the parent form is not really a form but a page with some buttons or if it's a form, it's not being rebuild properly in subform submit but just some of its data is manipulated.

Proposed resolution

We could have a generic dialog subform API used in all those places.
Such a solution has already been created in the Drupal LMS module and allows defining endless nesting of entities and other data structures with dialog forms on top of other dialog forms (the module allows to reference newly created entity which references another newly created entity to the parent entity and also passing data from one parallel dialog form to another where form steps are different forms).

This dialog subform API can be extracted form the Drupal LMS module and placed in Drupal Core or in another contrib module initially. Currently it adds possibility to code endlessly nested and chained forms including entity forms and Views on a single page.

Structure:

  1. Modal subform plugin manager
  2. Attribute class
  3. Plugin interface, base class, some working plugins
  4. Forms
  5. Modal subform endpoint controller
  6. Example use case (complex entity reference widget)

Remaining tasks

  1. Create contrib
  2. Extract code
  3. Add proper test coverage (some functional JS coverage already exists in the Drupal LMS module)
  4. Add documentation
  5. Make some use of it
  6. Integrate into core

User interface changes

None or various improvements in different places in core and contrib (see example dialog subform usage at the top)

Introduced terminology

API changes

New dialog subform API

Data model changes

Release notes snippet

Feature request
Status

Active

Version

11.1 🔥

Component

ajax system

Created by

🇵🇱Poland Graber

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024