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

SchemaResolver with array of objects of dynamic #109

Open
abelchun39 opened this issue Nov 28, 2017 · 2 comments
Open

SchemaResolver with array of objects of dynamic #109

abelchun39 opened this issue Nov 28, 2017 · 2 comments

Comments

@abelchun39
Copy link

I had an array of objects A and each of object contains filter. Each filter options will display different kinds of forms objects dynamically.

Based on the issue #22, the dynamic done in the first layer of the object. But I have array of objects A that doesn't work for each display.

var schema = {
  "properties": {
    "ObjectA": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": { "filter": ...., "criteria": { "dependOn": ['filter'] } }
      }
    }
  }
}
var dynamicSchema = {
  "age": { type: "Object",  number: 21 },
  "country": { type: "Object", name: "US" }
}


var BrutusinForms = brutusin["json-forms"];
this.bf = BrutusinForms.create(schema);
this.bf.schemaResolver = (names, data, cb) => {
  data.ObjectA.map((obj, ind) => {
  schemas["$.ObjectA[" + ind + "].criteria"] = dynamicSchema[obj.filter]
  }
  cb(schemas);
}
this.bf.render(this.$refs.manageContainer);

The name always outputs schemas["$.demographic[#].criteria"] no matter which filter I add.
If I add schemas["$.demographic"], it works for me without the filter but the dynamic schema objects.

@idelvall
Copy link
Member

@OYE93
Copy link

OYE93 commented Nov 2, 2018

hello, did you solve this problem? I also meet this problem, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants