Problem/Motivation
ctools_views Block::blockSubmit() reads the exposed filter elements from $form['settings']['exposed'][...] (Block.php lines 512 and 519 in 4.1.1). That only works when the block is configured through Block Layout or Layout Builder, because core is asymmetric: buildConfigurationForm() and validateConfigurationForm() get the settings subform, while submitConfigurationForm() gets the parent form.
Block field follows the build/validate convention and passes the settings subform as $form, so $form['settings'] does not exist and each exposed filter emits:
Warning: Undefined array key "settings" in Drupal\ctools_views\Plugin\Display\Block->blockSubmit() Warning: Trying to access array offset on null in Drupal\ctools_views\Plugin\Display\Block->blockSubmit()
Worth fixing regardless of Block field: core #2948549proposes passing the subform to submitConfigurationForm() too, which would break ctools_views the same way in Block Layout itself.
Related: core #2948549 (root
inconsistency) and #3227026 (Layout
Builder counterpart); Block field #3536872
(same gap on the build side) and #3037221
(same code path).
Steps to reproduce
- View with a block display, "Configure filters" allowed, one exposed filter. Use a taxonomy autocomplete filter to see the data corruption, not just the warnings.
- Add a
block_fieldfield to a content type, widget "Configuration form" set to Full. - Edit a node, select the views block, set the exposed filter value, save. Warnings appear.
- Re-edit the node: the filter value is gone. The same block placed via /admin/structure/block works.
Found on ctools 4.1.1, Drupal 11.4.5, Block field 1.0.0-rc5, PHP 8.3.
Proposed resolution
Resolve the settings subform once at the top of the configure_filters branch and use it for both extractExposedValues() calls:
$settings_form = $form['settings'] ?? $form;Correct under both conventions, so it fixes Block field today and survives core #2948549. Patch attached, against 4.1.x.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | ctools-blocksubmit-settings-subform-compat.patch | 1.21 KB | joaopauloc.dev |
Issue fork ctools-3623416
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
joaopauloc.dev commentedComment #3
joaopauloc.dev commentedComment #6
joaopauloc.dev commentedComment #8
joaopauloc.dev commentedSeems like weird stuff with gitlab, how a comment can appear from 2022 if created this issue today :(
Anyway, here is the patch uploaded since i can't create the merge request properly.
Credits: sonnet. After my debug and I identified the difference of the submittion between adding the block with block layout and block field loking into the stack trace. I used sonnet to identify the difference between the modules. Also to write this issue description.
Comment #10
joaopauloc.dev commentedI create the mr from the incorrect version.
now it's fixed.
Comment #11
joaopauloc.dev commented