Skip to main content
Version: Current (v7.0.0-beta.3)

uiSchema oneOf and anyOf entries describe a field's own options where an allOf entry merges a list with them

Detect​

  • In your schema: a field with a oneOf or anyOf of its own and an allOf entry holding a list under the same keyword, whose options retrieveSchema() merges pairwise.
  • In your uiSchema: oneOf/anyOf entries for such a field, one per merged option.
  • On the rendered page: the selector labels each merged option after two options, as "A, C", and a title, widget, ui:initialValue or ui:required you set shows on other options than before.

Change​

Before, uiSchema.oneOf[i] described the merged option at i, its title, widgets, ui:initialValues and ui:required alike, and each merged option was labelled after one option only.

Now uiSchema.oneOf[i] describes the field's own option at i, which each option built from it reads, and each merged option is labelled after both, as "A, C" (#5930). Entries past the field's own options are ignored.

A field whose lists sit only in allOf entries has no list of its own, so each entry describes the merged option at its position, and entries written for the options before narrowing have to be rewritten for the options left (see An option both lists hold is offered alone).

import { RJSFSchema, UiSchema } from '@rjsf/utils';

const schema: RJSFSchema = {
type: 'object',
oneOf: [
{ title: 'A', properties: { a: { type: 'string' } } },
{ title: 'B', properties: { b: { type: 'string' } } },
],
allOf: [
{
oneOf: [
{ title: 'C', properties: { c: { type: 'string' } } },
{ title: 'D', properties: { d: { type: 'string' } } },
],
},
],
};
const uiSchema: UiSchema = { oneOf: [{ 'ui:title': 'u0' }, { 'ui:title': 'u1' }, { 'ui:title': 'u2' }, { 'ui:title': 'u3' }] };
// Before: Form offers 'u0', 'u1', 'u2' and 'u3'. After: 'u0, C', 'u0, D', 'u1, C' and 'u1, D', u2 and u3 ignored

Write one entry per option of the field's own list, and give an allOf option's label as its title:

const uiSchema: UiSchema = {
oneOf: [
- { 'ui:title': 'u0' },
- { 'ui:title': 'u1' },
- { 'ui:title': 'u2' },
- { 'ui:title': 'u3' },
+ { 'ui:title': 'uA' },
+ { 'ui:title': 'uB' },
],
};

See oneOf, anyOf, and allOf for how merged options are built and labelled.

Verify​

  • Each merged option shows the title, widgets, ui:initialValues and ui:required of the entry for the field's own option it was built from.

Also read: