Conflict with Inline Entity Form?

Created on 4 August 2022, almost 2 years ago
Updated 19 August 2023, 11 months ago

Problem/Motivation

Probably a bit of an edge-case, but I've found that Layout Builder Style (LBS) selections are sometimes not saved/applied if the block form in question includes an Inline Entity Form β†’ (IEF) complex widget. I suspect the same would hold true for the simple widget, but haven't explicitly tested that.

The set-up: I have a custom block type called Cards whose sole job is to be a container for Card entities. The child entities are styled based on a required 'Card Type' Layout Builder Style selection. The Cards block has a single entity reference revisions field that uses the complex IEF widget to add child Card entities. If I add Card block (inline) to a layout AND interact with the IEF widget in any way (add, remove or duplicate entities), any style selections/changes I also make are not saved.

At the moment I'm using microcode β†’ for the Card entities, but I've also tried other entity types (paragraphs, micro-content β†’ , other custom blocks) with the same result.

Steps to reproduce

Given the set-up above:

  1. Add a new page (with layout overrides enabled)
  2. Go to Layout
  3. Add a Cards block
  4. Create a couple Card entities via the IEF widget
  5. Select a Card Type (the Layout Builder Style)
  6. Click 'Add block'.

The selected Card Type style class does not appear in the block wrapper markup.

If I then 'Configure' the block, the Card Type I selected is gone. I can then re-select the Card Type and, provided I don't make any changes via the IEF widget, I can 'Update' the block and the selected style's class appears in the markup.

Proposed resolution

Not sure yet. Initial debugging indicates that the Layout Builder Styles submit handler _layout_builder_styles_submit_block_form() is never called in these cases. My first inclination was that IEF is doing something that interferes with the Layout Builder Styles submit handler, and that may well be the case. But this comment from layout_builder_styles.module made me wonder if LBS should be doing something to get ahead of other modules that might also interact with submit handlers:

// Our submit handler must execute before the default one, because the
// default handler stores the section & component data in the tempstore
// and we need to update those objects before that happens.
array_unshift($form['#submit'], '_layout_builder_styles_submit_block_form');

I'll provide more information as time allows to dig further, but thought I'd go ahead and post in case anyone has insights or runs into this.

Remaining tasks

Figure out what's going on.

User interface changes

?

API changes

?

Data model changes

?

πŸ› Bug report
Status

Active

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States justcaldwell

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΏπŸ‡¦South Africa alabandit

    Not sure if this is an edge case any more. Currently, Drupal 8/9/10 has 23000 installs of the Commerce Module which require Inline Entity Form.

    Not sure what would be the next step, will see if I can investigate as well.

    Commenting to add commerce to the search in case anyone else is also having this issue

    Required by: commerce, commerce_price, commerce_store, commerce_number_pattern, commerce_order, commerce_product, commerce_cart, commerce_checkout, commerce_log, commerce_payment, commerce_payment_example, commerce_promotion, commerce_tax

Production build 0.69.0 2024