Warning: Undefined array key "title" in Block->form() line 266 block.class.inc
Description of the bug
This error is shown in admin/structure/block/list when you have added a custom block on a layout and have made it reusable, but have not saved the layout yet.
Steps To Reproduce
To reproduce the behavior:
- Enable all errors in
admin/config/development/logging - Go to any layout
- Click on "Add block" in any region
- Select "Custom block" from the list of blocks
- Give the block a title
- Tick the "Make this block reusable" checkbox
- Provide an admin title and description
- Click "Add block", but do NOT save the layout changes yet
- Navigate to
admin/structure/block/listin another browser tab...
Actual behavior
The above-mentioned error is thrown.
Note: the error is only shown once and then goes away - if you refresh the page, you won't ever see it again, but it is logged in admin/reports/dblog if you don't have errors enabled.
Expected behavior
No error.
Additional information
Add any other information that could help, such as:
- Backdrop CMS version: 1.27.x-dev
- Web server and its version: Apache/2.4.56 (Debian)
- PHP version: 8.1.18
- Database sever (MySQL or MariaDB?) and its version: 10.3.27-MariaDB
- Operating System and its version: Lando 3.202 on Mac OS Ventura 13.5.2 (22G91)
- Browser(s) and their versions: Chrome 117.0.5938.92 (Official Build) (x86_64)
...I've gotten the same error also on the admin/structure/layouts/manage/%layout% page, after editing and re-saving a newly-created reusable block (with the layout changes not saved yet). So:
- create custom block and make it reusable
- save the block but NOT the layout
- re-edit the block
- re-save the block -> error
Confirming that this is an issue also with the second set of steps. @NormPlum you provided a PR for another issue that may be related or in the same "area" of Backdrop. Wondering if you might be interested in tackling this one? :)
I don't think this needs a separate PR as the issue is when you leave the Content field empty. If you perform the steps above but also add text to the Content field, the issue doesn't happen.
So if the other PR is committed that'll prevent people submitting the form without Content field and prevent this error.
Actually, that's not the case. The problem still exists even with your PR - it's a different bug. This is what I'm seeing with your other PR applied:
- Apply PR (https://github.com/backdrop/backdrop/pull/5141)
- Go to Layouts and edit the default layout
- On the sidebar, add a custom block. Enter text in the content and leave title empty
- Click the checkbox to make the block reusable
- Enter an admin label
- Save the block but don't save the Layout
- Click "Configure" to edit the layout you just created
- Click "Update block" (no need to save the Layout)
- Go to Reports > Recent log messages
There you'll see the error that was reported in the post. All of this after your PR.
I see. I was adding a block title. But it doesn't seem to be a required field for reusable blocks, so an empty title was causing the error.
I've unlinked the other PR and made a new one for this issue.