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

Show string field as multiple choice without enum #1570

Closed
2 of 3 tasks
dafeder opened this issue Jan 17, 2020 · 2 comments
Closed
2 of 3 tasks

Show string field as multiple choice without enum #1570

dafeder opened this issue Jan 17, 2020 · 2 comments

Comments

@dafeder
Copy link

dafeder commented Jan 17, 2020

Prerequisites

Description

I am wondering if there is an existing way to do this, or if this might be a good idea: I'm building a form around a schema that I don't own. Some of the fields in this existing schema are defined as open text fields, but I want to restrict the incoming values and present a multiple-choice "select" box. Can I do this entirely in the UI configuration? I realize it's a bit of an anti-pattern to hide validation rules in the UI, but there are benefits to my use-case in not forking the schema itself.

Expected behavior

I can define a ui:widget as "select" or "checkboxes" for a simple string fields, and define the available options in the ui configuration.

Actual behavior

A field must have enum values in the schema itself for a select box to be available as a form widget.

Version

Whatever the live playground is currently running? (1.8.1?)

@epicfaace
Copy link
Member

You could define a custom widget that does this, which reads values from uiSchema["ui:options"]["enum"] and renders a dropdown. Maybe we could also add it to react-jsonschema-form.

We do support an autocomplete option with the examples keyword, if that's useful at all: #1517

@stale
Copy link

stale bot commented Apr 15, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please leave a comment if this is still an issue for you. Thank you.

@stale stale bot added the wontfix label Apr 15, 2022
@stale stale bot closed this as completed May 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants