Problem/Motivation
Since the dragtable widget refactor in #3258972 (released in 8.x-1.11), EntityqueueDragtableWidget::formMultipleElements() relies on core to build the per-row Remove buttons. Core's WidgetBase::formMultipleElements() only adds them, and the AJAX wrapper, when the field cardinality is unlimited.
Subqueue items fields are unlimited, so queues work. But on a regular entity reference field with limited cardinality (e.g. 1 or 7) using this widget, editors can no longer remove a referenced item. The "Add item" control is also missing, because it reuses that AJAX wrapper; empty slots are rendered as plain autocomplete rows instead. An empty single-value field offers no way to add a reference at all. In 8.x-1.10 the widget built its own AJAX wrapper, Remove buttons and "Add item" control regardless of cardinality, so this is a regression after updating.
Related: #3258972 (the refactor), #3047463.
Steps to reproduce
Reproduced with Entityqueue 8.x-1.13 on Drupal 10.6.9 and 11.4.11 (the refactor has been in every release since 8.x-1.11).
Setup: add an entity reference field with "Allowed number of values: Limited" to any entity type (e.g. a node or block content type), and use the "Autocomplete (draggable table)" widget for it.
Missing Remove button
- Limit the field to e.g. 7 values.
- Save an entity with 7 references, then reopen it for editing.
Expected: each reference has a Remove button. Actual: there is no Remove button, so editors cannot remove references using the widget.
| 8.x-1.10: Remove on each row | 8.x-1.13: no Remove buttons |
|---|---|
![]() |
![]() |
Missing Add item control
- Limit the field to e.g. 3 values.
- Save an entity with 1 reference (or none), then reopen it for editing.
Expected: an "Add item" control is shown below the table. Actual: there is no "Add item" control; unused slots appear as plain autocomplete rows instead. An empty single-value field offers no way to add a reference at all.
| 8.x-1.13: no Add item, only an empty autocomplete row | With the fix: Add item control |
|---|---|
![]() |
![]() |
Workaround: set the field to unlimited cardinality (loses the item limit).
Proposed resolution
For fields with limited cardinality, in interactive (non-programmed) forms: add the AJAX wrapper, render one row per referenced item, add the per-row Remove button in the widget (reusing core's deleteSubmit()/deleteAjax()), and show "Add item" until the cardinality is reached.
Single-value fields use the table layout again, as in 8.x-1.10. Otherwise the field label and description are lost, because core does not use a table for them and the widget renders the row as a container.
Remaining tasks
- MR
- Tests for cardinality 1 and 2: remove (including the AJAX response), add, save, and save empty; label visible on a single-value field both filled and empty; required single-value field
- Manual testing on Drupal 10.6
- Review
User interface changes
Remove button and "Add item" control restored on limited-cardinality fields. Single-value fields use the table layout (as in 8.x-1.10), so the field label and description remain visible whether the field is filled or empty.
API changes
None.
Data model changes
None.
Generated with the help of an LLM.
| Comment | File | Size | Author |
|---|---|---|---|
| entityqueue-add-item-restored-below-limit.png | 61.18 KB | cadence96 | |
| entityqueue-add-item-missing-below-limit.png | 51.67 KB | cadence96 | |
| entityqueue-dragtable-after-1.13.png | 166.76 KB | cadence96 | |
| entityqueue-dragtable-before-1.10.png | 200.92 KB | cadence96 |
Issue fork entityqueue-3641317
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 #3
cadence96Opened MR !69. The pipeline is green. Setting to Needs review.
What the MR does
deleteSubmit()/deleteAjax()), and shows "Add item" until the cardinality is reached.Tests added
Testing
Tested manually in the browser on Drupal 10.6.9 (a full 7-value field, and a single-value field both empty and filled: remove, add and save). Automated: all new tests pass on 11.4; on 10.6.9 (PHPUnit 9.6) the new Functional test (data-provider cases run through a small wrapper), the Kernel test and the existing widget tests in
EntityQueueUiTestpass.The code and tests were written with the help of an LLM and reviewed by me.
Comment #6
amateescu commentedMade a few fixes and merged into 8.x-1.x, thanks!