Submit handler in Drupal Blocks configure form is never triggered

Created on 7 February 2025, about 1 month ago

Problem/Motivation

When using drupal blocks, the config form BlockSettingsForm::submitForm() is never called.
It appears that the js in drupal-block-settings.js is closing the modal on the submit button click, and just pulling the values in js from the form fields.

This is bypassing form validation and submit handlers, which can lead to invalid data.

I originally came across this when my blocks config form, which has a textarea with a ckeditor and the values were not being displayed in the gutenberg output.

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @loze
  • πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

    I think this needs to be handled similar to what I implemented for content blocks πŸ› Libraries attached to content block fields are not included in the editor Fixed using drupal's core ajax commands.

    I will try to write a patch/MR

    Also I think this is related ✨ Drupal block - Change and/or hide title Active

  • Merge request !214Improving DrupalBlock config forms β†’ (Open) created by loze
  • Pipeline finished with Success
    about 1 month ago
    Total: 341s
    #417920
  • πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

    I've done some work here to improve the drupalblock config form in MR214 and its working for me.

    The form now submits with the core drupal ajax and runs the block through the validation and submit handlers.

    I borrowed a lot of this from the context modules block reaction code. That module is similar to what we are doing here, in that it allows you to configure blocks via an ajax form outside of the core block layout UI. The main difference is the context module stores the configs in actual config files while we are storing the config data in the body of the content as json.

    you can see how the context module handles the bock config form here https://git.drupalcode.org/project/context/-/blob/5.x/src/Reaction/Block...

    This solves my initial issue of drupal blocks config fields that use ckeditor not saving values.

    This also solves the issue here ✨ Drupal block - Change and/or hide title Active because now we are including the whole block config form. It also allows other settings like items per page in views blocks and any 3rd part settings alters that were not working.

  • Pipeline finished with Success
    21 days ago
    Total: 274s
    #425855
  • Pipeline finished with Success
    21 days ago
    Total: 194s
    #425858
  • Pipeline finished with Success
    20 days ago
    Total: 304s
    #426778
  • Pipeline finished with Success
    20 days ago
    Total: 408s
    #426879
  • Pipeline finished with Success
    20 days ago
    Total: 188s
    #426881
  • Pipeline finished with Success
    20 days ago
    Total: 306s
    #426896
Production build 0.71.5 2024