react-jsonschema-form icon indicating copy to clipboard operation
react-jsonschema-form copied to clipboard

How do I eliminate the select dropdown when using anyOf?

Open zeckdude opened this issue 9 months ago • 1 comments

Prerequisites

What theme are you using?

core

What is your question?

I have this example schema in the playground:

{
  "title": "A registration form",
  "description": "A simple form example.",
  "type": "object",
  "required": [
    "firstName",
    "lastName"
  ],
  "properties": {
    "ipAddresses": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "string",
            "format": "ipv4"
          },
          {
            "type": "string",
            "format": "ipv6"
          }
        ]
      }
    }
  }
}

I'm trying to collect multiple IP addresses but when it shows the UI elements, it shows the text field (which I want) but it also shows a dropdown with Option 1 and Option 2 as the options (which I don't want). How can I remove that dropdown?

As a bonus, how can I implement validation based on the fact that this field should be an IP address?

As a second bonus, how can I set the section titles and field titles so it sounds more natural? Do I need to set that in the UI schema or in the JSON schema?

Image

zeckdude avatar Jan 28 '25 00:01 zeckdude