[2.0.0-rc2] Check attributes props default value

Created on 8 January 2025, 14 days ago

Problem/Motivation

default property in JSON schema: https://json-schema.org/understanding-json-schema/reference/annotations.

Some source plugins are using it to fill the default value of the form, when they extends SourcePluginPropValue because:

  • the source store only one config value called value
  • value data is validating to the prop schema

Examples:

  • UrlWidget
  • SelectsWidget
  • NumberWidget
  • CheckboxesWidget.
  • SelectWidget
  • CheckboxWidget.
  • TextfieldWidget
  • AttributesWidget

For AttributesWidget, it doesn't work well because the source is storing a string but the prop value is a mapping.

So, if we define such a default value in prop definition:

      default:
        class:
          - g-0

We get a fatal error.

(Defining g-0 as default value works, but this is an unexpected workaround because AttributesWidget ia able to create attributes value from classes list stored as a string)

See related UI Suite Bootstrap issue 🐛 Components: check attributes props default value Active

Proposed resolution

Straightforward fix: remove AttributesWidget from SourcePluginPropValue children. But we lose a feature.

Better fix: remove AttributesWidget from SourcePluginPropValue children AND implement a specific mecanism for

Best fix: Add a method to SourceInterface which is doing the opposite of SourceInterface::getPropValue() : instead of converting stored config value to expected prop data, convert valid prop data to storable config data, and use it in AttributesWidget.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇫🇷France pdureau Paris

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024