-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Prerequisites
- I have read the documentation
What theme are you using?
other
What is your question?
I'm working on a custom theme that also includes custom fields using a lightly modified copy core
FieldTemplate. One of the custom for a custom oneOf
property [1]. I'm dereferencing my schema and it looks like [2]. Because I don't want to show the selector for oneOf/anyOf I use "ui:fieldReplacesAnyOrOneOf": true
and "ui:field": "hidden"
which works fine. In addition I have set a field for '/schemas/specialString': StringOrReferenceField
to show my custom field. Now I want to still render the FieldTemplate
shell for the label, description and general accessibility however the props
that arrive don't contain that information. For reference the props of my custom field [3].
From looking at
react-jsonschema-form/packages/core/src/components/fields/SchemaField.tsx
Lines 292 to 296 in 63a860e
return ( | |
<FieldTemplate {...fieldProps}> | |
<> | |
{field} | |
{/* |
SchemaField
s FieldTemplate
and my own StringOrReferenceField
gets react-jsonschema-form/packages/core/src/components/fields/SchemaField.tsx
Lines 172 to 187 in 63a860e
const field = ( | |
<FieldComponent | |
{...props} | |
onChange={handleFieldComponentChange} | |
idSchema={idSchema} | |
schema={schema} | |
uiSchema={fieldUiSchema} | |
disabled={disabled} | |
readonly={readonly} | |
hideError={hideError} | |
autofocus={autofocus} | |
errorSchema={fieldErrorSchema} | |
formContext={formContext} | |
rawErrors={__errors} | |
/> | |
); |
What is the best way for me to get my custom StringOrReferenceField
to follow the FieldTemplate
including displayLabel, description, help, etc.
Thank you in advance
[1]
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Schema for special string",
"definitions": {
"name": {
"$id": "/schemas/specialString",
"type": "object",
"oneOf": [
{
"properties": {
"reference": {
"type": "string"
}
},
"required": [
"reference"
]
},
{
"properties": {
"static": {
"type": "string"
}
},
"required": [
"static"
]
}
]
},
}
}
[2]
{
"type": "object",
"required": [
"url",
"access_token",
"input_field"
],
"properties": {
"url": {
"type": "string",
"description": "The URL of the API endpoint"
},
"access_token": {
"$id": "/schemas/specialString",
"type": "object",
"oneOf": [
{
"properties": {
"reference": {
"type": "string"
}
},
"required": [
"reference"
]
},
{
"properties": {
"static": {
"type": "string"
}
},
"required": [
"static"
]
}
],
"description": "The access token for fun"
},
"input_field": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}