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

current per-field customization break JSON rules #3695

Open
4 tasks done
nagaozen opened this issue May 26, 2023 · 0 comments · May be fixed by #3881
Open
4 tasks done

current per-field customization break JSON rules #3695

nagaozen opened this issue May 26, 2023 · 0 comments · May be fixed by #3881
Labels
feature Is a feature request help wanted templates Related to the templates capabilities of RJSF

Comments

@nagaozen
Copy link

nagaozen commented May 26, 2023

Prerequisites

What theme are you using?

core

Version

5.x

Current Behavior

Currently, as described in the documentation https://rjsf-team.github.io/react-jsonschema-form/docs/advanced-customization/custom-templates, it is possible to customize per-field Field, Template and Widget user interfaces. The problem with the current model is that assigning the function/class directly in the uiSchema causes it to no longer be valid application/json.

{
  "ui:field": MyCustomField,
  "ui:ArrayFieldTemplate": MyArrayTemplate
}

Expected Behavior

A much consistent and superior alternative, in my humble opinion, would be to assign the name of the key associated with the templates transmitted during the initialization of the Form, as is done with widgets and fields.

import LayoutFieldTemplate from '~/lib/rjsf/templates/LayoutFieldTemplate.js'
import Form from '@rjsf/core'

const templates = {
  "layout": LayoutFieldTemplate
}

function App () {
  return <Form templates={templates} />
}

and when necessary to change the template, use it like:

{
  "ui:template": "layout"
}

Steps To Reproduce

No response

Environment

- OS: Windows 22H2 (19045.2965)
- Node: 16.20.0
- npm: 8.19.4

Anything else?

No response

@nagaozen nagaozen added bug needs triage Initial label given, to be assigned correct labels and assigned labels May 26, 2023
@heath-freenome heath-freenome added feature Is a feature request help wanted templates Related to the templates capabilities of RJSF and removed bug needs triage Initial label given, to be assigned correct labels and assigned labels May 26, 2023
nagaozen added a commit to nagaozen/react-jsonschema-form that referenced this issue Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is a feature request help wanted templates Related to the templates capabilities of RJSF
Projects
None yet
2 participants