Add/remove a nullable object

My Json schema includes a nullable object with some required field. So the object itself is optional but if it is included, the fields must be initialised. It is currently represented as a group with the required fields marked with “*” but unfortunately this looks like these fields are obligatory and so the object itself. If the user starts typing in any of the objects fields, it is created and included in the data object and it doesn’t seem possible to remove it.

Is it possible to do the following:

  1. Instead of the object, initially render a + button which is used by default for array elements.

  2. When added, render the object with a delete icon so it can be removed.

I have tried to represent the object in the JSON schema as a singleton array with max length of 1 but this seems to be an undesirable workaround as the representation detail is encoded in the data layer. And representing the object as an array rather than an optional field may be confusing for the users.

[original thread by Albert Gevorgyan]

We don’t support this out of the box but you can implement this behavior via a custom renderer. See this tutorial for instructions.

What you want to do is to replace the MaterialObjectRenderer with an own copy which adds your advanced use cases.