Problem/Motivation
Steps to reproduce
Setup :
- Display Builder beta 2
- UI Patterns 2 dev release
- UI Suite DaisyUI dev release
Build the default display with Layout Builder :
- Remove everything
- Use Card as section
- Map
- Image field with slot image
- Title field with slot title
- Body field with slot text
- Tags field with slot actions (use component per item —> badge —> map label with Field Formatter > Label)
- Save
GOTO Manage Display :
- Activate Display Builder with Default profile
- Goto Display Builder and Publish the initialization from Layout Builder
- Save the whole Card as preset
- The preset doesn’t appear
In logs we have following Warning and errors :
WARNING #01
Warning: Undefined array key "source_id" in Drupal\display_builder\Entity\PatternPreset->getContextsFromComponent() (line 257 of /var/www/html/web/modules/contrib/display_builder/src/Entity/PatternPreset.php)
#0 /var/www/html/web/core/includes/bootstrap.inc(104): _drupal_error_handler_real()
#1 /var/www/html/web/modules/contrib/display_builder/src/Entity/PatternPreset.php(257): _drupal_error_handler()
#2 /var/www/html/web/modules/contrib/display_builder/src/Entity/PatternPreset.php(226): Drupal\display_builder\Entity\PatternPreset->getContextsFromComponent()
#3 /var/www/html/web/modules/contrib/display_builder/src/Entity/PatternPreset.php(158): Drupal\display_builder\Entity\PatternPreset->getContextFromSource()
#4 /var/www/html/web/modules/contrib/display_builder/src/Entity/PatternPreset.php(187): Drupal\display_builder\Entity\PatternPreset->getContexts()
#5 /var/www/html/web/modules/contrib/display_builder/src/Plugin/display_builder/Island/PresetLibraryPanel.php(64): Drupal\display_builder\Entity\PatternPreset->areContextsSatisfied()
#6 /var/www/html/web/modules/contrib/display_builder/src/IslandPluginBase.php(315): Drupal\display_builder\Plugin\display_builder\Island\PresetLibraryPanel->build()
#7 /var/www/html/web/modules/contrib/display_builder/src/Plugin/display_builder/Island/PresetLibraryPanel.php(104): Drupal\display_builder\IslandPluginBase->reloadWithGlobalData()
#8 /var/www/html/web/modules/contrib/display_builder/src/Event/DisplayBuilderEventsSubscriber.php(169): Drupal\display_builder\Plugin\display_builder\Island\PresetLibraryPanel->onPresetSave()
#9 /var/www/html/web/modules/contrib/display_builder/src/Event/DisplayBuilderEventsSubscriber.php(128): Drupal\display_builder\Event\DisplayBuilderEventsSubscriber->dispatchToIslands()
#10 /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php(246): Drupal\display_builder\Event\DisplayBuilderEventsSubscriber->onPresetSave()
#11 /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php(206): Symfony\Component\EventDispatcher\EventDispatcher::{closure:Symfony\Component\EventDispatcher\EventDispatcher::optimizeListeners():241}()
#12 /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php(56): Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
#13 /var/www/html/web/modules/contrib/display_builder/src/Controller/ApiControllerBase.php(96): Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
#14 /var/www/html/web/modules/contrib/display_builder/src/Controller/ApiController.php(612): Drupal\display_builder\Controller\ApiControllerBase->createEventWithEnabledIsland()
#15 /var/www/html/web/modules/contrib/display_builder/src/Controller/ApiController.php(383): Drupal\display_builder\Controller\ApiController->dispatchDisplayBuilderEvent()
#16 [internal function]: Drupal\display_builder\Controller\ApiController->saveAsPreset()
WARNING #02
Warning: Undefined array key "source" in Drupal\display_builder\Entity\PatternPreset->getContextsFromComponent() (line 257 of /var/www/html/web/modules/contrib/display_builder/src/Entity/PatternPreset.php)
#0 /var/www/html/web/core/includes/bootstrap.inc(104): _drupal_error_handler_real()
#1 /var/www/html/web/modules/contrib/display_builder/src/Entity/PatternPreset.php(257): _drupal_error_handler()
#2 /var/www/html/web/modules/contrib/display_builder/src/Entity/PatternPreset.php(226): Drupal\display_builder\Entity\PatternPreset->getContextsFromComponent()
#3 /var/www/html/web/modules/contrib/display_builder/src/Entity/PatternPreset.php(158): Drupal\display_builder\Entity\PatternPreset->getContextFromSource()
#4 /var/www/html/web/modules/contrib/display_builder/src/Entity/PatternPreset.php(187): Drupal\display_builder\Entity\PatternPreset->getContexts()
#5 /var/www/html/web/modules/contrib/display_builder/src/Plugin/display_builder/Island/PresetLibraryPanel.php(64): Drupal\display_builder\Entity\PatternPreset->areContextsSatisfied()
#6 /var/www/html/web/modules/contrib/display_builder/src/IslandPluginBase.php(315): Drupal\display_builder\Plugin\display_builder\Island\PresetLibraryPanel->build()
#7 /var/www/html/web/modules/contrib/display_builder/src/Plugin/display_builder/Island/PresetLibraryPanel.php(104): Drupal\display_builder\IslandPluginBase->reloadWithGlobalData()
#8 /var/www/html/web/modules/contrib/display_builder/src/Event/DisplayBuilderEventsSubscriber.php(169): Drupal\display_builder\Plugin\display_builder\Island\PresetLibraryPanel->onPresetSave()
#9 /var/www/html/web/modules/contrib/display_builder/src/Event/DisplayBuilderEventsSubscriber.php(128): Drupal\display_builder\Event\DisplayBuilderEventsSubscriber->dispatchToIslands()
#10 /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php(246): Drupal\display_builder\Event\DisplayBuilderEventsSubscriber->onPresetSave()
#11 /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php(206): Symfony\Component\EventDispatcher\EventDispatcher::{closure:Symfony\Component\EventDispatcher\EventDispatcher::optimizeListeners():241}()
#12 /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php(56): Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
#13 /var/www/html/web/modules/contrib/display_builder/src/Controller/ApiControllerBase.php(96): Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
#14 /var/www/html/web/modules/contrib/display_builder/src/Controller/ApiController.php(612): Drupal\display_builder\Controller\ApiControllerBase->createEventWithEnabledIsland()
#15 /var/www/html/web/modules/contrib/display_builder/src/Controller/ApiController.php(383): Drupal\display_builder\Controller\ApiController->dispatchDisplayBuilderEvent()
#16 [internal function]: Drupal\display_builder\Controller\ApiController->saveAsPreset()
#17 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
ERROR
TypeError: Drupal\display_builder\Entity\PatternPreset::getContextFromSource(): Argument #1 ($source_id) must be of type string, null given, called in /var/www/html/web/modules/contrib/display_builder/src/Entity/PatternPreset.php on line 257 in Drupal\display_builder\Entity\PatternPreset->getContextFromSource() (line 221 of /var/www/html/web/modules/contrib/display_builder/src/Entity/PatternPreset.php).
Other building scenario : If we build directly from Display Builder (without pre-building and importing from Layout Builder) the preset is getting saved and is usable.
But be aware we get following errors in log messages (don’t know if that is relevant …) :
Type : ui_patterns
…
Location : https://ui-suite-demo.ddev.site/api/display-builder/preset/698dab65d2d70...
Referrer : https://ui-suite-demo.ddev.site/admin/structure/types/manage/article/dis...
Message : Entity not found in context
Severity : Error
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | Capture d’écran 2026-03-01 à 15.29.10.png | 536.96 KB | g4mbini |
Issue fork display_builder-3573122
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 #2
pdureau commentedI will have a look soon and try to fix it for beta3
Comment #3
pdureau commentedHi Michaal,
Thanks for the detailed instructions. I am not reproducing. The only difference between my test and your description is the Display Builder version: I am on
1.0.0-dev, you are on1.0.0-beta2.I can test again but can you share your entity view display config entity first?
Comment #4
pdureau commentedTested with
1.0.0-beta2. Still not reproducing.Comment #5
grimreaperHello,
I do not reproduce too. Tested with latest dev version of 1.0.x and latest version of UIP 2.
Tested on ui_suite_bootstrap.
Comment #6
pdureau commentedNot easy to reproduce, so moved out of beta3 scope.
Comment #7
steveoriolI added the following lines as a workaround for now. It seems to be working for the moment...
web/modules/contrib/display_builder/src/Entity/PatternPreset.php(line 257) :Comment #8
pdureau commentedHii Steve,
So you are reproducing the issue? That's great, thanks a lot. Can you propose a MR?
With a phpunit, it would be even better :)
Moving back to beta3 because we are waiting the next release of UI Patterns, so we may have time to merge this one before.
Comment #10
steveoriolThere you go, I did an MR. But I don't know if it's normal for the props table to be empty or not...
Comment #11
pdureau commentedI am reproducing by the way and it seems related to #3574921: Instance::moveToSlot() error when an ancestor is a not a SDC which is about some source data being lost, especially the
source_idSo, the root cause will be fixed there, but anyway it i good to have a more defensive behaviour thanks to your MR. I will review.
Comment #12
pdureau commentedComment #13
pdureau commentedComment #14
g4mbiniIt saves the preset now that I can re-use, but in the saved presets we lose all styles that were added.
Comment #15
pdureau commentedLet's wait #3574921: Instance::moveToSlot() error when an ancestor is a not a SDC to be sure
Comment #16
pdureau commentedComment #17
mogtofu33 commentedComment #18
pdureau commentedMichael, is it better now #3574921: Instance::moveToSlot() error when an ancestor is a not a SDC has been merged?
Comment #19
g4mbiniStill ... Presets is saved but when I use it, Styles used are not saved in the preset.
I attached a screenshot.
Comment #20
mogtofu33 commented