Error: Call to undefined method getLayout() when adding or editing sections in Layout Builder with layout_builder_backgrounds

Created on 11 October 2024, 7 days ago

Problem/Motivation

When attempting to add a new section or edit an existing section in the Layout Builder, the following error occurs:

Error: Call to undefined method Drupal\layoutbuilder_extras_live_update\Form\LayoutBuilderExtrasConfigureSectionForm::getLayout() in layout_builder_backgrounds_form_layout_builder_configure_section_alter() (line 22 of modules/contrib/layout_builder_backgrounds/layout_builder_backgrounds.module).

This issue seems to be related to an incompatibility between the `layout_builder_backgrounds` and `layoutbuilder_extras_live_update` modules. Specifically, the `getLayout()` method is missing, causing the error.

I created a patch based on a similar issue found in the `layout_builder_styles` module: https://www.drupal.org/project/layout_builder_styles/issues/3180131 Incompatible with Layout Builder UX module Needs review

**Drupal Core Version:** 10.3.5
**Layout Builder Backgrounds:** 1.0.0
**Layout Builder Extras Live Update:** 1.0.8

Steps to reproduce

1. Install and enable the `layout_builder_backgrounds` and `layoutbuilder_extras_live_update` modules.
2. Go to the Layout Builder for any content type or block.
3. Attempt to add a new section or edit an existing section.
4. The error will be triggered, and the operation will fail.

Proposed resolution

- Apply the patch created based on a similar issue in `layout_builder_styles` that resolves the method call to `getLayout()`.
- Modify the `layout_builder_backgrounds_form_layout_builder_configure_section_alter()` function to correctly reference a method available within the form class.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇵🇹Portugal developer-rocha

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

Comments & Activities

Production build 0.71.5 2024