Define how block settings should be presented in the UI

Created on 30 October 2024, 17 days ago

Overview

Some blocks can be configured via block settings when placed into a page. We have at least two options for presenting the block settings to the user:

1. Use the settings form via the ::blockForm() method on the block plugin.

Pros: UI is the same as the existing Drupal block UI
Cons: Will this always work inside React? What if we want to map field values to block settings? (see 📌 Define `props` in the context of Block components Active )

2. Use the block config schema to build a settings form

Pros: Autogenerated forms will be easier to handle in the client
Cons: What if ::blockForm() allows dynamic values or uses other advanced features of forms?

One possible idea is to converge these two options: for fully validatable blocks, allow the block plugin to opt out of providing a form, and automatically generate it from the config schema instead. Then the Drupal core block UI will use same automatic form layout as the XB UI will use, but on the XB side we can augment the form elements if we need to (e.g. to provide dynamic field mappings).

Proposed resolution

?

User interface changes

📌 Task
Status

Active

Version

0.0

Component

Config management

Created by

đŸ‡Ŧ🇧United Kingdom longwave UK

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

Comments & Activities

  • Issue created by @longwave
  • đŸ‡Ŧ🇧United Kingdom longwave UK
  • đŸ‡Ŧ🇧United Kingdom longwave UK
  • 🇧đŸ‡ĒBelgium wim leers Ghent 🇧đŸ‡ĒđŸ‡ĒđŸ‡ē

    Cons: Will this always work inside React?

    I don't see why not? I'd like to see @bnjmnm comment on this aspect.

    Cons: What if we want to map field values to block settings? (see 📌 Define `props` in the context of Block components Active )

    ℹī¸ I'm assuming that by , you mean DynamicPropSources aka product requirement 7.1 Token.

    Why would that make sense? Isn't that what Block plugins already have the context functionality for? This sounds like it'd be a confusing duplication of that functionality. IMHO we should limit

    2. Use the block config schema to build a settings form

    Pros: Autogenerated forms will be easier to handle in the client
    Cons: What if ::blockForm() allows dynamic values or uses other advanced features of forms?

    This cannot work AFAICT.

    See my detailed write-up at #3462241-8: [PP-1] Decorate the SDC plugin manager and allow components defined in code →

    One possible idea is to converge these two options: for fully validatable blocks, allow the block plugin to opt out of providing a form, and automatically generate it from the config schema instead.

    Interesting idea! 🤔 But â€Ļ config schema is not rich enough in its metadata to convey everything. Lots of validation constraints use logic to define valid values, conditional values, and so on.

    Hence it sadly follows that it's impossible to auto-generate equivalent forms from a fully validatable block plugin's config schema! đŸĢ¤

Production build 0.71.5 2024