Fatal error when adding an extra field in a Layout from the Layout Library

Created on 4 February 2025, 3 months ago

Problem/Motivation

I use Layout Library (drupal.org/project/layout_library) in a project. I have detected that I cannot use any field block based on an extra field because I'm getting a fatal error:

Error: Call to a member function getContextValue() on null in extra_field_plus_form_alter() (line 304 of modules/contrib/extra_field_plus/extra_field_plus.module).

Steps to reproduce

- Install Layout Library
- Create a layout
- Add an extra field block

Proposed resolution

The problem is that the layout library module is not providing the `display` context. However, I noticed that it's not really needed because the `display` context is only used in order to get the `view_mode` and this information is already a context available in the form state. So, it's enough getting directly the `view_mode` instead of getting the `display` to query the `view_mode`.

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇪🇸Spain unstatu

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024