Problem/Motivation

The "Add another item" and "Remove" buttons rebuild the form over AJAX, which means the form is written to the form cache. Any object holding that form has to survive being serialized and restored.

This is easy to trip over without knowing to look for it. Embedding the element in a block plugin's settings form and editing that block through Layout Builder's off-canvas dialog will fail if the plugin injects services into readonly promoted properties, because DependencySerializationTrait restores them after construction. Nothing about the failure points at this module, so it costs time to diagnose.

Proposed resolution

Add a short section to README.md covering the requirement: objects holding the form need DependencySerializationTrait, and on PHP versions below 8.4 the properties holding injected services cannot be readonly. Mention that this applies anywhere the containing form is cached, including block configuration forms edited through Layout Builder.

Remaining tasks

Review.

User interface changes

None.

API changes

None. Documentation only.

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

darvanen created an issue. See original summary.

darvanen’s picture

Assigned: darvanen » Unassigned
Status: Active » Needs review
darvanen’s picture

Parent issue: » #3608015: [meta] Version 2.x