New config schema data type: weight

Created on 22 February 2024, 4 months ago

Problem/Motivation

There are many config objects that use a weight attribute to sort elements. This is usually done using an integer schema data type. The problem is that this data type is not validatable, and explicit constraints need to be added for the attribute to be validatable. Since this is such a common use case, it would be benefitial having a weight schema data type.

Proposed resolution

Create a new weight schema data type. The data type might have a default value for the value range, which could be overriden using some additional parameter to modify the range of valid values.

Remaining tasks

  • Create a new schema data type weight
  • Add corresponding tests for the data type
  • Change all the weight config schema attributes to use the new data type
✨ Feature request
Status

Active

Version

11.0 πŸ”₯

Component
Configuration entityΒ  β†’

Last updated about 14 hours ago

Created by

πŸ‡ͺπŸ‡ΈSpain guiu.rocafort.ferrer Barcelona

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

Comments & Activities

  • Issue created by @guiu.rocafort.ferrer
  • πŸ‡ͺπŸ‡ΈSpain guiu.rocafort.ferrer Barcelona

    I have been looking a little bit more on the topic, and i found a configuration attribute system.site.weight_select_max. This is set to 100 by default on site install ( see core/modules/system/config/install/system.site.yml ).

    One option to make this data type validatable, would be having a callback to check the value of system.site.weight_select_max, and sets Range constraints for min: -VALUE, max: VALUE.

    This does not seem to be respected by core.extensions.yml, which sets a value of 1000 for the install profile used.

    I see three possible ways to deal with this:

    • Change system.site.weight_select_max to have a value of 1000, then the core.extensions would be valid
    • Change the site install behaviour, to add the install profile with a weight value of 100
    • Keep the core.extension weights as type integer, and leave it as an exception.
Production build 0.69.0 2024