React-jsonschema-form: [Question] oneOf boolean not showing properties on selection

Created on 19 Jun 2019  路  2Comments  路  Source: rjsf-team/react-jsonschema-form

Prerequisites

Description

Hi, I am trying to use "oneOf" of type "boolean". However, oneOf with type:"boolean" does not support properties on selection, works if I use "object" - see here

I want a behaviour that supports collapsible field on toggle to make my form less convoluted, I'm open to workarounds or suggestions. Many thanks in advance.

Steps to Reproduce

  1. Go to https://mozilla-services.github.io/react-jsonschema-form/#eyJmb3JtRGF0YSI6ZmFsc2UsInNjaGVtYSI6eyJ0aXRsZSI6IlRvZ2dsZSIsInR5cGUiOiJib29sZWFuIiwib25lT2YiOlt7ImNvbnN0Ijp0cnVlLCJwcm9wZXJ0aWVzIjp7IkFscGhhYmV0cyI6eyJ0eXBlIjoic3RyaW5nIiwiZW51bSI6WyJhYmMiLCJkZWYiXX0sIkFscGhhYmV0MiI6eyJ0eXBlIjoic3RyaW5nIiwiZW51bSI6WyJkZWYiLCJnaGkiXX19fSx7InRpdGxlIjoiRGlzYWJsZSIsImNvbnN0IjpmYWxzZX1dfSwidWlTY2hlbWEiOnt9fQ==
  2. Check "Toggle"
  3. No additional properties show up. Was expecting Alphabets and Alphabets2 to show up when I toggle

Expected behavior

Expand and show additional properties when I set toggle to true

Actual behavior

Additional properties/schemas did not show when I set toggle to true

Version

v1.6.1

question

Most helpful comment

Thanks @epicfaace , had a look at your suggestion and came up with this which is pretty much what I want.
Sample here
Will close this now!

All 2 comments

That's not a valid schema for oneOf. Since the type of the entire form is "boolean", it's not possible to store properties in it unless the type of the form is "object".

You might want to check out the "Schema dependencies" example for something closer to what you want: https://react-jsonschema-form.readthedocs.io/en/latest/dependencies/#dynamic

Thanks @epicfaace , had a look at your suggestion and came up with this which is pretty much what I want.
Sample here
Will close this now!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

elyobo picture elyobo  路  3Comments

ebower12 picture ebower12  路  3Comments

Eric24 picture Eric24  路  3Comments

videni picture videni  路  3Comments

n1k0 picture n1k0  路  3Comments