Comments (5)
There's the enumNames
jsonschema property which allows defining labels for enums, though for booleans that'd mean having this property without an explicit enum
defined (as it's implicit as [true, false]
):
const schema = {type: "boolean", enumNames: ["Yes", "No"]};
const uiSchema = {"ui:widget": "radio"};
Odd, and unlikely to be used in existing JSON schemas out there...
Having a new ui:labels
uiSchema property seems to be the simplest way to go:
const schema = {type: "boolean"};
const uiSchema = {
"ui:widget": "radio",
"ui:labels": ["Yes", "No"]
};
We could also add support for options to widgets:
const schema = {type: "boolean"};
const uiSchema = {
"ui:widget": {
name: "radio",
labels: ["Yes", "No"]
}
};
The latter would require a much larger internal refactoring and would be probably slightly more cumbersome to write, though the feature might be useful to other widgets as well (including custom ones).
Thoughts?
from react-jsonschema-form.
Thinking of it a little more, I could probably live with support provided by using enumNames right from the schema. As a bonus, the patch is a three liner.
const schema = {type: "boolean", enumNames: ["Yes", "No"]};
const uiSchema = {"ui:widget": "radio"};
from react-jsonschema-form.
@chmac quickly put a patch in #81 so we can stare at code. Would this be enough to you?
from react-jsonschema-form.
@n1k0 Certainly looks like it would do exactly what we want. Being able to pass in the values, like Yes / No would cover most cases where we'd have thought about building our own ui:widget
.
from react-jsonschema-form.
Fixed by #81.
from react-jsonschema-form.
Related Issues (20)
- Duplicate widgets when rending OpenAPI's discriminated unions
- Usage Example is missing Form import
- Widgets unusable under Antd v5 using a dark theme (wrong ConfigProvider context passed down) HOT 3
- How to figure out the changed `formData` object property from inside `onChange` callback? HOT 4
- Warning: React does not recognize the `errorSchema` and Invalid DOM property `autocomplete`. HOT 1
- DOCUMENTATION Issue: Wrong method signature? HOT 1
- Schema defines standalone checkbox as mandatory, but asterisk is not rendered. HOT 2
- I would like to make a default change to the look of all input fields HOT 5
- Adding required field in nested if/then/else not working correctly HOT 2
- FormData is not received based on schema properties HOT 1
- Select bug when multiple oneOf are nested HOT 2
- How can I cite this? HOT 6
- RJSF anyOf customization HOT 3
- Validation error when multiple $ref references point to a single definition HOT 3
- not working about validation HOT 3
- Passing ui options down to array items HOT 3
- MUI number input label UI issue with non-numeric input HOT 1
- Publish v6 release candidate with support for Bootstrap 5 HOT 1
- Can not replace "integer" widget HOT 4
- Omit Extra Data not behaving as expected on submit for allOf (if then) schemas along with additionalProperties set to false blocking form submission HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-jsonschema-form.