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:
- Migrate Drupal from 10.6 to 11.3.9
- Add the layout_builder_reusable_blocks module with composer
- enable the layout_builder_reusable_blocks module
- enable the dblog module
- in the configuration menu, configure the layout_builder_reusable_blocks module as following
- Save the configuration
- Go to an existing node, in layout mode
- Choose an existing block, contextual menu > configure
- Change a value in a text field
- Save the configuration
- Expected result : the block is saved and the configuration popup disappears
- Result: nothing happens at first saving. The modal is still opened. Fortunately,
at second click, The changes are saved. - Open the logs in reports >recent messages
- Watch this one: 'form' ->
The submitted value in the Weight for row 1 element is not allowed
- check "Show warning message when editing reusable blocks"
- check "Allow editing reusable blocks"
- check "Make all blocks reusable by default"
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | core--layout_builder_reusable_blocks--issues-3590810--comment-16590987.patch | 907 bytes | fabrondeau |
Issue fork layout_builder_reusable_blocks-3590810
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
Comment #2
fabrondeau commentedComment #3
fabrondeau commentedComment #4
fabrondeau commentedWhen 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 ?