question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ordering of schema-depended fields

See original GitHub issue

Prerequisites

  • I have read the documentation;
  • In the case of a bug report, I understand that providing a SSCCE example is tremendously useful to the maintainers.

Description

Hello there, thank you for the great work on this project. I am exploring the use of schema dependencies but I encounter a trouble in ordering the depended fields. I created a minimal example here: https://codesandbox.io/s/8kw2wq6z08

In this example, there are two selects. When every of them is selected “yes”, a depended field will be triggered to display. So “Select A” triggers “Textbox A” and “Select B” triggers “Textbox B”.

What I am trying to achieve is an ordering of “Select A”, “Textbox A”, “Select B”, “Textbox B”, but setting ui:order as is (you can modify the uiSchema to uiSchema_not_working) will throw the following error:

Invalid root object field configuration:uiSchema order list contains extraneous properties

If there is a way to correctly define the ordering, could you please kindly inform?

Copy-paste the schema here:

{
  "type": "object",
  "properties": {
    "Show first name?": {
      "type": "string",
      "enum": ["yes", "no"]
    },
    "Show family name?": {
      "type": "string",
      "enum": ["yes", "no"]
    }
  },
  "dependencies": {
    "Show first name?": {
      "oneOf": [{
        "properties": {
          "Show first name?": {
            "enum": ["yes"]
          },
          "First name": {
            "type": "string"
          }
        }
      }, {
        "properties": {
          "Show first name?": {
            "enum": ["no"]
          }
        }
      }]
    },
    "Show family name?": {
      "oneOf": [{
        "properties": {
          "Show family name?": {
            "enum": ["yes"]
          },
          "Family name": {
            "type": "string"
          }
        }
      }, {
        "properties": {
          "Show family name?": {
            "enum": ["no"]
          }
        }
      }]
    }
  }
}

The uiSchema I was trying to set:

{
  "ui:order": ["Show family name?", "Family name", "Show first name?", "First name"]
}

Version

React 16.0.0 react-jsonschema-form latest

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:13
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

12reactions
Pruxiscommented, Feb 23, 2018

You can use a wildcard like this:

    'ui:order': [
      'description',
      'method',
      'url',
      'headers',
      '*', // all undefined ones come here.
      'variable',
      'results',
    ],
4reactions
lingxiaoyangcommented, Feb 23, 2018

@Pruxis This wildcard: (1) cannot define the order of undefined ones; (2) requires that all undefined ones are grouped together in display.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ordering of schema-depended fields · Issue #823 · rjsf-team ...
In this example, there are two selects. When every of them is selected "yes", a depended field will be triggered to display. So...
Read more >
Developers - Ordering of schema-depended fields - - Bountysource
I am exploring the use of schema dependencies but I encounter a trouble in ordering the depended fields. I created a minimal example...
Read more >
Schema.Field.Order (Apache Avro Java 1.8.2 API)
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate...
Read more >
Hippocampal-medial prefrontal circuit supports memory ...
Here, we provide a critical test of recent theories suggesting hippocampal (HPC) and medial prefrontal (MPFC) involvement in integration, both ...
Read more >
What is the order in which Custom field type,Fields,Content ...
I am creating a custom field type, Content type and List definition. I have a custom field type inheriting from Multicolumn value and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found