Rjsf-team from React-jsonschema-form Repository

Apache License 2.0

Open
populate default on UI but do not save them if untouched. #3157

Issue Opened
Rjain-eightfold Opened Issue On Sep 29th 2022, 7:41

Rjain-eightfold

Prerequisites

What theme are you using?

bootstrap-4

Is your feature request related to a problem? Please describe.

the library is amazing. there is only one of my requirement which I am not able to achieve.

I understand that all the default are auto populated on the form by propagating from parent to child. What I want to achieve is that I wan to only show the default values on the UI but do not want to save them.

USE CASE: I am using the same schema for multiple tenants. and default specified in schema can also change (sometime). So when the schema default change I do not want to edit the json for all the tenants if they have never touched those fields.

Describe the solution you'd like

I am looking for an easier way to show defaults but not save default if the field is not manually touched.

if there is any best way to override this behaviour. or a code pointer which can refer, it will be a big help.

https://github.com/rjsf-team/react-jsonschema-form/blob/6e6c558a2bc4719c16ce644bc53e3feb4ce4e697/packages/utils/src/schema/getDefaultFormState.ts

Describe alternatives you've considered

  1. I tried removing all the defaults from schema before sending it to ui but that results in not knowing the defaults at all.
  2. tried removing 'default' and add them to 'description' (which works fine for most cases but boolean and integer fields still look confusing and also propagation logic from parent to child will not work.)
Comment
Vsoni-eightfold commented on 2 months ago

Vsoni-eightfold

Yes, this will be great to have.

About Repository

A React component for building Web forms from JSON Schema.
Language: TypeScript
Star: 12070
Fork: 1990
Watchers: 12070
Open Issues: 388
https://github.com/rjsf-team/react-jsonschema-form
Apache License 2.0
Last updated: 05 Dec 2022
Tropics: