Dynamic forms and schemas


#1

I am creating a sort of checklist app and we have a feature with which users can customize the checklist questions.

So currently I am having a checklist collection which collects all the instances when they use this checklist.
Approach 1 :
Create a schema dynamically and pass it to autoform.
But my question is how to create this sort of dynamic collection and schemas, is this the right approach for solving this problem?

Approach 2:
Have a collection which defines the master layout for the checklist and the fields are stored here and create the schema on the fly when the checklist if rendered.
My question here is how to create a schema from all the stored values in master layout collection, and if we do it, where is the new collection defined and how the data will be save.

Thanks for your time and advice.


#2

For 1 you can try:

Schema:

checklist : {
  type: Array,
  optional: true,
},

'checklist.$': {
  type: Object,
  blackbox: true,
  optional: true
},
'checklist.$.question': {
  type: String,
  optional: true
},

Form:
Build the form and parse it like it is shown here: serializeJson


#3

how about saving the values entered in this form, will this go to a different collection or the same collection schema which you gave before?


#4

serializeJson just parses the form for you. It´s up to you to save the given object to a collection.


#5

ok, let me try, thanks