react-jsonschema-form
react-jsonschema-form copied to clipboard
Conditionally set user input in one form field as value for another form field
Prerequisites
- [X] I have read the documentation
What theme are you using?
antd
What is your question?
Suppose there are three properties in the schema. 1. First name 2. select menu with 2 option (1. Self 2. other) 3. Generated First name.
For example user wrote "abc" in First name form field and then selected Self in the select menu. On selecting self value of the Generated First name should be set as "abc". If user selected other in select menu than user should manually type for generated first name.
Please help in building the schema for the same if it is possible.
We should not use react in this case, for example we can implement above requirement using onChange function in some way like this but this can't be used for implementation >
if (e.target.value) === 'Self' { setFormData({...formData, generatedFirstName: firstName}) }
Requirement is to get dynamic schema.
Try using a if-then-else or a dependency? https://json-schema.org/understanding-json-schema/reference/conditionals.html. Although note that RJSF is still using the older dependency keyword in the JSON Schema 7 spec and not the newer ones
This issue has been automatically marked as possibly close 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.
This issue was closed because of lack of recent activity. Reopen if you still need assistance.