Formatters for empty fields do not render with layout builder enabled

Created on 15 July 2019, almost 6 years ago
Updated 21 April 2023, about 2 years ago

Tentatively opening as bug report but might also be a support request to get direction for debugging in Markup module.

Problem/Motivation

A markup field does not show on nodes with layout builder enabled. It does show in the Layout Builder form, but not on the node view. The markup module Maintainer spent quite some time on debugging and couldn't find an error in the module.

Steps to reproduce:

- Install https://www.drupal.org/project/backfill_formatter β†’ module
- Create some taxonomies
- Create entity reference field to terms on any content type (i.e., Article)
- Try to add that entity reference field as block with layout builder (i.e., On Article content type's default display mode)
- Add "Backfill terms" as formatter
- Create some articles with similar terms (The motto of backfill formatter is it will automatically select content based on terms tagging, in order they set in the field formatter hence the term backfill)
- Visit the articles you created you won't see that block.

Proposed resolution

Let the field appear on node view.

πŸ› Bug report
Status

Needs work

Version

10.1 ✨

Component
Layout builderΒ  β†’

Last updated 1 day ago

Created by

πŸ‡©πŸ‡ͺGermany anruether Bonn

Live updates comments and jobs are added and updated live.
  • Blocks-Layouts

    Blocks and Layouts Initiative. See the #2811175 Add layouts to Drupal issue.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

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

  • The setting has been moved to the block settings.
    Schema fix.

  • last update about 2 years ago
    30,289 pass, 4 fail
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Environment: PHP 8.1 & MySQL 5.7 updated deps
    last update about 2 years ago
    29,268 pass, 2 fail
  • last update about 2 years ago
    29,300 pass
  • last update about 2 years ago
    30,322 pass
  • Status changed to Needs review about 2 years ago
  • Status changed to Needs work about 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    As a bug this will need test coverage.

    Also since we are adding a new configuration "hide_for_empty" think we may need an upgrade path.

    Definitely a change record for the new setting though.

  • First commit to issue fork.
  • last update over 1 year ago
    30,434 pass
  • I've replaced the latest patch with a merge request (with some fixes).

  • Pipeline finished with Success
    over 1 year ago
    Total: 674s
    #37643
  • Pipeline finished with Failed
    about 1 year ago
    Total: 993s
    #142589
  • Pipeline finished with Success
    about 1 year ago
    Total: 994s
    #143156
  • πŸ‡¦πŸ‡ΊAustralia uqjhawk3

    rerolled for 10.2.7

  • πŸ‡¦πŸ‡ΊAustralia hoffismo Brisbane, Queensland

    Creating a patch for 10.2.x

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    Fixes are made on on 11.x (our main development branch) first, and are then back ported as needed according to our policies. Also, 10.2 is in security mode now.

  • πŸ‡·πŸ‡΄Romania bbu23

    Was previously using patch from #30.
    After upgrading to 10.3.2, tried patch from #42. Didn't work, the values were not being saved.

    After evaluating the differences between the three, #43 has the schema definition at formatter level and uses the config from the formatter key. #30 which was previously working, also uses the config from the formatter key.

    #42 and the MR have the schema one level higher. Because of this, the values don't get saved.

    Patch #43 works as expected.

  • πŸ‡ΊπŸ‡ΈUnited States sonfd Portland, ME

    First, I just want to note that we should not be iterating on patches since we're using an MR. Any work and iteration should happen in the MR.

    Second, I'd propose that the logic of this new field be flipped: instead of "Hide when empty" and defaulting to checked, use "Show when empty" and default to unchecked. I will add an MR with this alternate approach.

  • Pipeline finished with Failed
    9 days ago
    Total: 219s
    #490185
  • Pipeline finished with Failed
    9 days ago
    Total: 479s
    #490195
  • Pipeline finished with Success
    9 days ago
    Total: 389s
    #490245
  • Pipeline finished with Failed
    9 days ago
    Total: 508s
    #490269
  • Pipeline finished with Failed
    9 days ago
    #490294
  • Pipeline finished with Running
    9 days ago
    #490361
  • Pipeline finished with Canceled
    9 days ago
    #490373
  • πŸ‡ΊπŸ‡ΈUnited States sonfd Portland, ME

    MR !12052 refactors original approach to use a "show block when field is empty" checkbox rather than a "hide for empty" checkbox. This MR also includes updates to tests to test the new option.

    As a result, I'm going to mark as Needs review and remove the needs tests tag.

    My instinct is to also hide MR !5111, but I'll leave that to a maintainer.

  • Pipeline finished with Success
    9 days ago
    #490379
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    New configuration key will need an upgrade path + upgrade path test

  • πŸ‡ΊπŸ‡ΈUnited States sonfd Portland, ME

    @smustgrave -

    Sorry, but I want to make sure I'm understanding you correctly.

    Currently the FieldBlock's default configuration has a value for the new config field that matches the FieldBlock's behavior pre-patch.

    Are you saying that we need an update hook to update all FieldBlocks to set a value for the new config option and then a test to make sure update hook works properly? Or something else?

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    If this key could appear on any FieldBlock then it would need an upgrade path. Good rule of thumb if you go into a config page, make no changes, click save, config export and there is a change then it needed an upgrade path.

    and then a test to make sure update hook works properly

    That's correct, there are a few example in core but don't have them super handy right now.

  • πŸ‡ΊπŸ‡ΈUnited States sonfd Portland, ME

    Thank you, I understand now.

  • Note that the update hook should probably only target the default layouts (the entity view displays).

    There could be thousands+ of nodes/entities with overridden layout data that have field blocks. Writing an update hook to load, check the nodes overridden layout for field blocks, then resave the nodes does not sound realistic. As long as the behavior for a field block that does not have any value for the new property is the same as the new property having empty value, I think this should be fine.

  • Pipeline finished with Success
    9 days ago
    Total: 624s
    #490579
  • πŸ‡ΊπŸ‡ΈUnited States sonfd Portland, ME

    I added an update hook that updates FieldBlocks to set show_when_empty to FALSE, but I'm not sure if there's more I need to do there. See my previous note about whether more is needed.

    But I am not sure how to go about writing a test for the update hook.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    RemovePathKeyTest may be a good example

    Essentially the test would be

    Load a fieldBlock and verify the key DOES NOT exist

    Run updates

    Load the same block and verify the key DOES exist.

  • πŸ‡ΊπŸ‡ΈUnited States sonfd Portland, ME

    Thank you @smustgrave, I think I see how it could be done now. But I have run out of time in the short term, I'll try to get back to this to add the test of the upgrade path sooner rather than later.

  • Pipeline finished with Failed
    3 days ago
    Total: 698s
    #495281
  • Pipeline finished with Success
    2 days ago
    Total: 460s
    #495850
Production build 0.71.5 2024