Problem/Motivation
When using DraggableListBuilder for a Config Entity listing page, you have to change the way you specify your rows from how EntityListBuilder works. To wit:
class MyEntityListBuilder extends EntityListBuilder {
public function buildRow(EntityInterface $entity) {
$row['label'] = $this->getLabel($entity);
$row['id']= $entity->id();
return $row + parent::buildRow($entity);
}
// ...
}
Compare to:
class MyEntityListBuilder extends DraggableListBuilder {
public function buildRow(EntityInterface $entity) {
$row['label'] = $this->getLabel($entity);
$row['id']['#markup'] = $entity->id();
return $row + parent::buildRow($entity);
}
// ...
}
Note the extra ['#markup'] that is required for all fields in the row, except for label. Without that, the listing form will not render correctly; which headers and columns are hidden get mixed up and the wrong ones hidden.
This makes DraggableListBuilder not a proper subclass of EntityListBuilder, as its API is different in silent, undocumented ways. (Fancy academic version: It's violating the Liskov Substitution Principle.)
Thanks to Tim Plunkett for helping locate this issue after I spent 90 minutes scratching my head about it. :-)
Proposed resolution
Whatever special treatment that label gets in order to make the #markup sub-property optional should be applied to all fields.
Remaining tasks
Do it.
API changes
I'd argue none. This is just a bug.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | 2514970-1.patch | 800 bytes | tim.plunkett |
Issue fork drupal-2514970
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 #1
tim.plunkettMaybe something like this?
Comment #9
dewalt commentedThe values should be sanitized, to not allow output HTML tags directly. See https://www.drupal.org/project/drupal/issues/3037027.
Comment #18
kumudbNot sure but we can fix with this code,
Modify DraggableListBuilderTrait or override buildRow() in DraggableListBuilder:
Comment #21
smustgrave commentedThis came up as the daily BSI target
Seems the original issue was opened 10 years ago and looking at LanguageListBuilder is this still an issue?
Comment #22
smustgrave commentedSo believe this can be closed, looked in the DraggableListBuilderTrait and see it's using plain_text now.
If still an issue in D11 please re-open.