Change Config Entity List Builder form to support global configuration

Created on 28 April 2025, 19 days ago

Problem/Motivation

The Verify Email configuration is currently a Drupal provided list of config entities. This means that configuration can only be provided for each Verify Email entity. But future planned config settings only make sense for the whole site, not individual verification forms.

This change aims to override the list builder form to allow global settings to be added.

This issue is intended to enable further issues to add settings, so will only add a label to demonstrate the change.

Proposed resolution

Looking for similar forms in Drupal core, the most similar to what's needed is the Search Pages configuration (/admin/config/search/pages). However, this is derived from DraggableListBuilder, so is structured slightly differently from what the Verify Email form needs.

The most similar form I've found in core is the Block Layout form (/admin/structure/block), which is controlled by the BlockListBuilder in the block core module (/core/modules/block/src/BlockListBuilder.php), so that is a useful file to follow for this change.

The basic strategy is to implement the FormInterface interface, and override the render() method to replace the form building logic.

Remaining tasks

On the VerifyEmailListBuilder class:

  • Add implements FormInterface to the class definition
  • Add string $theme and \Symfony\Component\HttpFoundation\Request $request properties to the class
  • Add a constructor to the class, initializing promoted properties of \Drupal\Core\Theme\ThemeManagerInterface and \Drupal\Core\Form\FormBuilderInterface
  • Override the createInstance static function to initialize the entity and injected dependencies
  • Override the render() function, passing in theme and request, which should be saved in the class properties. It should call $this->formBuilder->getForm($this) and return the result
  • In the buildForm() function, Initialize the render array for the form, and add a details container for global settings. Place a markdown item inside as a placeholder for future global options
  • Also in buildForm function, add a second details item. Add a button to add a new Verify Email form. Add a table, calling the buildHeader function to generate the header.
  • Loop through the entities property, and call buildRow. Add the result to the #rows array of the table
  • Add validateForm and submitForm forms. These can be empty functions for now

Also ensure the VerifyEmailSetupTest tests still pass, and add a check that the new markdown is present.

User interface changes

Slight change to the appearance of the config form.

API changes

None.

Data model changes

None.

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇮🇪Ireland lostcarpark

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

Comments & Activities

Production build 0.71.5 2024