Stop assuming default Field Widget settings suffice — add Field Widget settings support to `experience_builder.generated_field_explicit_input_ux: prop_field_definitions`

Created on 27 May 2025, 7 days ago

Overview

XB generates an input UX for SDCs and code components automatically.

It achieves that through shape matching (see docs/shape-matching.md).

The results are stored in the Component config entity's source-specific settings — more precisely: type: experience_builder.generated_field_explicit_input_ux's prop_field_definitions. That has a key for every SDC prop, and a value that contains the field type, field storage settings, field instance settings, cardinality, default value, structured data prop expression and … the field widget plugin ID.

But … in principle it's possible to configure widgets differently. Right now, XB assumes that the default widget settings will suffice.

It's even possible that contrib/custom modules want to implement hook_storage_prop_shape_alter() to control widget settings. Right now, to achieve that, they'd have to alter the results of \Drupal\experience_builder\Plugin\ExperienceBuilder\ComponentSource\GeneratedFieldExplicitInputUxComponentSourceBase::buildConfigurationForm(), which would be a fairly complex undertaking.

Proposed resolution

  1. Modify \Drupal\experience_builder\PropShape\StorablePropShape to contain widget settings.
  2. Modify \Drupal\experience_builder\PropShape\CandidateStorablePropShape to similarly contain widget settings, and update the hook_storage_prop_shape_alter() documentation. ⚠️👈 This is what makes this a stable blocker: this modifies the public API.
  3. Change config schema:
    diff --git a/config/schema/experience_builder.schema.yml b/config/schema/experience_builder.schema.yml
    index 5f8d95ecb..10229bc9b 100644
    --- a/config/schema/experience_builder.schema.yml
    +++ b/config/schema/experience_builder.schema.yml
    @@ -372,15 +372,16 @@ experience_builder.generated_field_explicit_input_ux:
                 type: field.field_settings.[%parent.field_type]
                 # Optional *if* the default instance settings should be used.
                 requiredKey: false
    -          # After a field type is selected, a field widget must be picked.
    -          # @todo MUCH later: widget settings.
               field_widget:
                 type: string
    -            label: 'Default field widget'
    +            label: 'Field widget'
                 constraints:
                   PluginExists:
                     manager: plugin.manager.field.widget
                     interface: '\Drupal\Core\Field\WidgetInterface'
    +          field_widget_settings:
    +            type: field.widget.settings.[%parent.type]
    +            label: 'Widget settings'
               # Then finally, a default value must be picked for every REQUIRED prop, using the aforementioned widget.
               # This value uses the field type's default value config schema, and will be simplified to a
               # StaticPropSource's `value`.
    
  4. User interface changes

Feature request
Status

Active

Version

0.0

Component

Config management

Created by

🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

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

Comments & Activities

Production build 0.71.5 2024