Modeling enumns with different value for "label" and "option"

Hi all,

I was looking the way to model an enum where the visible label is different than the underlying value.

I found the following issue #990 with this PR #1591

You can see in the code that even the tests (as of v2.5.0) expect that the label is the same as the value.

I’m not sure if this limitation is just my mental model. Let’s assume that I have a multi-language form. Having the value and label to be the same, forces me to define rules (SHOW/HIDE) based on changing strings. IMHO a more robust and maintainable schema ui is where the rules are based on the value (and not what is displayed to the user).

In plain HTML, a the options of a select have value attribute and the visible label to the user can be different.

  <option value="1">Option 1</option>
  <option value="2">Option 2</option>
  <!-- other options -->

In the example of vanilla renders, the code is setting the value attribute, but the problem is that value passed is the label.

Not sure if I’m missing something or this is a known limitation.

Many thanks for your support

[original thread by Iván Perdomo]

Hi! We support enums with different labels via the oneOf construct of const, title tuples, e.g.

    myproperty: {
        oneOf: [
            {const: 'foo', title: 'My Foo'},
            {const: 'bar', title: 'Bar'},
            {const: 'foobar', title: 'FooBar'}

The tests you linked just check some basic functionality and are therefore not related to this control.

At the moment we only support this construct in React Material, Angular Material and Vue Vanilla but not in React Vanilla.

Adding the support for this to React Vanilla should be straightforward. So in case you need it there we would happily accept a contribution or we could prioritize this feature with our professional support offerings.