Check if layout builder extra field component is defined by an Extra Field plugin before attempting to add a settings form

Created on 21 May 2024, 8 months ago

Problem/Motivation

The module currently doesn't check the source of the extra field component in `extra_field_plus_form_alter()` before attempting to discover the `$fieldPluginId` or to load a settings form using `$extraFieldPlusDisplayManager->getSettingsForm(...)`. If the extra field was provided using `hook_entity_extra_field_info()`, the `$fieldPluginId` will not exist in `$extraFieldInfo` and the call to `$extraFieldPlusDisplayManager->getSettingsForm(...)` using the missing field plugin ID will fail.

Steps to reproduce

With the extra `extra_field_plus` module installed, create an extra field using `hook_entity_extra_field_info()` and attempt to add it to an entity display using Layout Builder (I discovered this while attempting to add an "EVA: Entity Views Attachment" defined field).

The operation should fail along with PHP notices / errors in the site's log.

Proposed resolution

Check if the extra field being processed is in fact defined by an Extra Field plugin. See the attached patch which checks if a `plugin_id` exists for the current `field_name` in `$extraFieldInfo` before doing any further processing.

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΏπŸ‡¦South Africa Daniel Bornman

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

Comments & Activities

  • Issue created by @Daniel Bornman
  • πŸ‡ΏπŸ‡¦South Africa Daniel Bornman
  • πŸ‡ΏπŸ‡¦South Africa Daniel Bornman
  • πŸ‡ͺπŸ‡ΈSpain tuwebo

    I think this might the case when using a module like entity_print, since I am running in similar issue. I'll try to provide more feedback since I've just run into it.

  • πŸ‡ͺπŸ‡ΈSpain tuwebo

    Patch 3448459-3--stop-form-altering-non-extra-field-plugin-layout-builder-components.patch correctly applies and solve the issue for my use case:
    Drupal: 10.3.6
    Extra Field (extra_field): 8.x-2.3
    Extra Field Plus: Extra Field Settings Provider (extra_field_plus): 3.0.0-beta4
    Entity Print (entity_print): 8.x-2.14

    I am able to properly add/edit a "View PDF" extra field using the layout builder.

    Thanks @Daniel Bornman

Production build 0.71.5 2024