Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I eliminate the select dropdown when using anyOf? #4469

Open
1 task done
zeckdude opened this issue Jan 28, 2025 · 1 comment
Open
1 task done

How do I eliminate the select dropdown when using anyOf? #4469

zeckdude opened this issue Jan 28, 2025 · 1 comment

Comments

@zeckdude
Copy link

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 zeckdude added needs triage Initial label given, to be assigned correct labels and assigned question labels Jan 28, 2025
@nickgros
Copy link
Contributor

nickgros commented Feb 7, 2025

Hi @zeckdude , some other folks have tried to do this and it kind of depends on your schema. We have some suggestions in this issue. Check that out and let us know if any of those work.

For validation, you can use ajv-formats, which supports ipv4 and ipv6 as formats. Here is some documentation about how to use it in RJSF.

You can add titles and descriptions using the "title" and "description" fields in the schema or the ui:title and ui:description fields in the UI Schema. It all depends on what best fits your use case. Here's some more documentation on this.

@nickgros nickgros added awaiting response and removed needs triage Initial label given, to be assigned correct labels and assigned labels Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants