Settings form broken: Field layout_builder__layout is unknown.

Created on 5 June 2024, 7 months ago
Updated 9 July 2024, 5 months ago

Problem/Motivation

After install I get this WSOD error when viewing the settings form.

InvalidArgumentException: Field layout_builder__layout is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 616 of core/lib/Drupal/Core/Entity/ContentEntityBase.php).
Drupal\Core\Entity\ContentEntityBase->get() (Line: 135)
Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage->getSectionList() (Line: 72)
Drupal\layout_builder\Plugin\SectionStorage\SectionStorageBase->insertSection() (Line: 111)
Drupal\lb_plus\Form\SettingsForm->buildForm()
call_user_func_array() (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 284)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Steps to reproduce

  1. Install module.
  2. Enable "use layout builder" in "manage display" config page of article content type
  3. Go to /admin/config/content/layout-builder-plus
🐛 Bug report
Status

Active

Version

2.1

Component

Code

Created by

🇮🇹Italy trickfun

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

Comments & Activities

  • Issue created by @trickfun
  • 🇿🇦South Africa MrVee

    Experiencing this same issue on Drupal 10.2.7

  • This completely prevents a user from changing module settings in the admin interface, short of modifying the config YAML.

    Please fix this.

  • Even if I add an IF that skips using the entity_type_id of menu_link_content (this is the one that causes the issue for me, since the settings form is picking the first one using the layout builder, this is what it picks for me), I still get an error:

    Drupal\Component\Plugin\Exception\PluginNotFoundException: The "layout_twocol_section" plugin does not exist. Valid plugin IDs for Drupal\Core\Layout\LayoutPluginManager are: layout_onecol, with_sidebar in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).
    Drupal\Core\Plugin\DefaultPluginManager->getDefinition() (Line: 16)
    Drupal\Core\Plugin\Factory\ContainerFactory->createInstance() (Line: 83)
    Drupal\Component\Plugin\PluginManagerBase->createInstance() (Line: 116)
    Drupal\layout_builder\Section->getLayout() (Line: 218)
    Drupal\lb_plus\Element\LayoutBuilderPlus->buildAdministrativeSection() (Line: 127)
    Drupal\lb_plus\Element\LayoutBuilderPlus->layout() (Line: 99)
    Drupal\lb_plus\Element\LayoutBuilderPlus->preRender()
    call_user_func_array() (Line: 113)
    
  • 🇺🇸United States tim bozeman

    I'm sorry that's happening. I made a wrong assumption that every site would have those layouts when I hard coded those two layout_id's on line 110 and 113 of SettingsForm.php.

    Maybe that part should look up what layout ID's are available? Or maybe even just make that a static page that just shows some example markup for the colors if anything at all. As a work around until we get a chance to fix it, I think it's pretty safe to just comment out lines 77 through 116 😓

  • Yes, I found out I can view the form that way. Another workaround could be to add a try/catch.

    A proper solution would be to use some static example markup that showcases some blocks in a layout, I think.

  • 🇺🇸United States tim bozeman

    Yes, I agree. Trying to put a random Layout Builder element on the settings page was a bad idea. Sorry about that 😅

  • I guess priority should be "Major" since not everyone is affected.

  • This patch is just a workaround that removes the layout form element.

Production build 0.71.5 2024