Giter VIP home page Giter VIP logo

Comments (6)

idelvall avatar idelvall commented on August 18, 2024

Maybe this works for you:

  1. Set type1and type2values as schemas in themselves:
var typeSchemas = {
  "type1": {
    "type": "object",
    "properties": {
      "title": {
        "type": "string",
        "title": "Title 1"
      },
      "gender": {
        "type": "string",
        "title": "Gender",
        "enum": [
          "m",
          "f"
        ]
      }
    },

  },
  "type2": {
    "type": "object",
    "properties": {
      "title": {
        "type": "string",
        "title": "Title 2"
      },
      "otherfield": {
        "type": "string",
        "title": "Some other otherfield"
      }
    }
  }
};

and change the resolver to:

function (names, data, cb) {
    var schemas = new Object();  
    schemas["$.nextfields"] = typeSchemas[data.type];
    cb(schemas);
}

from json-forms.

bernhardh avatar bernhardh commented on August 18, 2024

Thank you for your reply!
Ok, maybe I am stupid and can't transfer your suggestions to the code, but please have a look at:
https://jsfiddle.net/ajzmgkh4/

from json-forms.

idelvall avatar idelvall commented on August 18, 2024

The reason is that this schema is different to the previous one (it does not have a nextfields property)

from json-forms.

bernhardh avatar bernhardh commented on August 18, 2024

Ok, the short answer is: Yes I am too stupid to transfer your example. :)

Just for documentation purpose: https://jsfiddle.net/ajzmgkh4/1/

Thank you for your help!

from json-forms.

idelvall avatar idelvall commented on August 18, 2024

:)

from json-forms.

hxh-robb avatar hxh-robb commented on August 18, 2024

https://jsfiddle.net/hxh_robb/xk663z01/

I've added a new feature called "appendedProperties" to meet this requirement without using schemaResovler. Since schemaResovler is a kind of behavior for "dynamic" additional properties rendering(What I mean "dynamic" is that the additional properties definition is a CRUD record, the schemaResovler might made an ajax call for that and generate a returned schema). "appendedProperties" is much more suit for that if one just need a "fixed" additional properties definition.

from json-forms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.