I have an array with complex items. These array items are actually two strings that are selected from onOfs.
Example (also on Stackblitz):
const schema = {
$schema: 'http://json-schema.org/schema#',
$id: 'ObjectsWithOneOfInArrayExample',
type: 'object',
properties: {
myArray: {
type: 'array',
items: {
type: 'object',
properties: {
letter: {
type: 'string',
oneOf: [
{
const: 'A',
title: 'A is the first letter in the English alphabet',
},
{
const: 'B',
title: 'B is the second letter in the English alphabet',
},
],
},
romanNumber: {
type: 'string',
oneOf: [
{ const: 'I', title: 'I is the first roman number' },
{ const: 'II', title: 'II is the second roman number' },
],
},
},
},
},
},
};
My uischema looks like follows:
const uischema = {
type: 'Group',
elements: [
{
type: 'Control',
scope: '#/properties/myArray',
options: {
elementLabelProp: 'letter', // actually displays 'letter/const' but 'letter/title' would be better here
detail: {
type: 'HorizontalLayout',
elements: [
{
type: 'Control',
scope: '#/properties/letter',
},
{
type: 'Control',
scope: '#/properties/romanNumber',
},
],
},
},
},
],
};
which renders to:
As you can see, elementLabelProp
targets the const
component in letter
. Technically, this makes sense as this is acutally the value for the letter
in the data. However, in the UI it would be better if the label for a collapsed array item would be the title
in the oneOf
. Is that possible (without rewriting the whole renderer)?
Maybe this is somewhat related to this topic.