Problem/Motivation

Hello,
Thank you for having created this module. It seems to be able to replace a patch I was using before.
This is a bug, I'm facing on Drupal 11.3.9, after a migration from 10.6.
Migrating a website from Drupal 10.6 to Drupal 11.3.9 and adding the layout_builder_reusable_blocks module returns an error when configuring previous blocks, not the new ones.

Steps to reproduce

Editing old blocks:

  1. Migrate Drupal from 10.6 to 11.3.9
  2. Add the layout_builder_reusable_blocks module with composer
  3. enable the layout_builder_reusable_blocks module
  4. enable the dblog module
  5. in the configuration menu, configure the layout_builder_reusable_blocks module as following
  6. - check "Show warning message when editing reusable blocks"
    - check "Allow editing reusable blocks"
    - check "Make all blocks reusable by default"

  7. Save the configuration
  8. Go to an existing node, in layout mode
  9. Choose an existing block, contextual menu > configure
  10. Change a value in a text field
  11. Save the configuration
  12. Expected result : the block is saved and the configuration popup disappears
  13. Result: nothing happens at first saving. The modal is still opened. Fortunately, at second click, The changes are saved.
  14. Open the logs in reports >recent messages
  15. Watch this one: 'form' -> The submitted value in the Weight for row 1 element is not allowed
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

    Comments

    fabrondeau created an issue. See original summary.

    fabrondeau’s picture

    Issue summary: View changes
    fabrondeau’s picture

    Issue summary: View changes
    fabrondeau’s picture

    When saving the block in the layout builder, the method doValidateForm is called (web/core/lib/Drupal/Core/Form/FormValidator.php).
    In this file, at line 243, I can fetch the 'delta' key, which contains the concerned rows.
    When the row is number 1, a #default_value is set to 0, but the #value value is empty ''.
    The other rows values are set:
    - row 2 #default_value is set to 1 and #value is 0
    - row 3 #default_value is set to 2 and #value is 1
    - row 4 #default_value is set to 3 and #value is 2

    So I've prepared a first patch where the #value for the row 1 would be -1 (#default_value - 1). See the attached file.

    Maybe the 0 #default_value has a special treatment anywhere else in the core ?