angularjsangular-schema-form

What's the relation between schema and form in angular-schema-form?


In my angular project I need to create some forms dynamically. I did some googling for this and found a module angular-schema-form. It seems this is exactly what I want, but the problem is I do not understand how to keep schema and form. What is the relation between schema and form?

I read the documentation from form types but it is not very helpful to me. I don't want to use this module like HIT and TRY. I first want to understand the concept: what is the relation between schema and form?


Solution

  • To try to address the basic question:

    What is the relation between schema and form?

    To put things into simple terms, perhaps it is easiest to think of it like this. To create the form, you have three pieces of JSON:

    Here's a very crude and very simple example of the flexibility the form object gives you:

    Taking the person object example above, if you don't make use of the form object (i.e. it just contains "*") then angular-schema-form will build you a form based on the schema. It would therefore have input fields for sex and age. Those fields may, or may not, be in the format, or order, or have other properties that you want. You may then optionally use the form object to instruct angular-schema-form how you want it to construct the form. For instance, you could use the form to make it so that the form only contains a field for age but not sex.

    So the model is your data, and the schema describes the structure of that data. In simplistic terms, the form provides a further layer of mapping and configuration to your form, overriding the default form that would be created based on the schema alone.

    Does that help?