Headings for enum arrays with uniqueItems=true?

Hi,

The default renderer (MaterialEnumArrayRenderer as far as I can tell) for enum arrays with uniqueItems=true, renders elements as checkboxes. That’s fine, but is it somehow possible to get JSON Forms to add a heading for each array?

1 Like

Hi @jva,

Instead of enum you can also use a oneOf: [{const: <value>, title: <label>}]. This way you can define labels for your values within the JSON Schema. See the docs here.

Alternatively you can use our i18n support to customize the labels. See the docs here.

Hi Stefan,

Thanks.

I will try out your suggestion.

Hi @sdirix,

I see now, that I can customize individual oneOf-elements as you wrote, but I would really like to add a heading at the oneOf-level, just above the individual checkboxes. Is there a way to do that?

Screen Shot 2022-10-24 at 15.26.00 2

I’m sorry if my original post was unclear.

I am also facing same issue, unable to add heading/label to HorizontalLayout having uniqueItems=true. Is there any workaround? Is there any way to just add a label without any control?

At the moment that’s not possible declaratively. You will need to register a custom MaterialEnumArrayRenderer for this. See this guide on how to reuse the existing renderer.

There are two ways of adding labels via the UI Schema:

  • There is a Label element, e.g.
    {
      type: "Label",
      text: "My information to display"
    }
    
  • There is the Group element, e.g.
    {
      type: "Group",
      label: "My information to display",
      elements: [
        // place your existing UI Schema here
      ]
    }