Model
The model is a native JSON object. VueFormGenerator will modify this model if the values of the fields change. Model can be a multi-level object. In this case the model of field will be like this:
1
model: "address.country"
Copied!

Example

1
{
2
"id": 1,
3
"type": "personal",
4
"name": "Rozella Hickle",
5
"username": "Kelton.Dicki",
6
"password": "adGlGG8hTq",
7
"email": "[email protected]",
8
"address": {
9
"streetC": "343 O'Conner Stravenue Apt. 183",
10
"city": "East Traceyfurt",
11
"country": "Nepal",
12
"zipcode": "17779",
13
"geo": {
14
"lat": "-21.0406",
15
"lng": "86.5714"
16
}
17
},
18
"phone": "031.053.8042 x33435",
19
"website": "abraham.net",
20
"dob": -196498331535,
21
"time": "02:47:20",
22
"age": 53,
23
"rank": 7,
24
"role": "user",
25
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/saulihirvi/128.jpg",
26
"skills": [
27
"ReactJS",
28
"CSS3"
29
],
30
"language": "it",
31
"status": true,
32
"created": 1461100485088
33
}
Copied!

Merge & multiple models

If you would like to edit more models, first you have to merge these objects to a work object. For this, there is a helper function:
1
VueFormGenerator.schema.mergeMultiObjectFields(schema, objs)
Copied!

Parameters

  • schema: schema object with fields. Merge only the multi: true fields
  • objs: array of models

Return

Returns the merged JSON object like this:
1
{
2
"time": "02:47:20",
3
"address": {},
4
"status": true
5
}
Copied!
The function only set those value of properties, where multiple mode is enabled multi: true in the fields and the values in every models are the same value.

Create new empty model

You can create a new model with default values. For this use the VueFormGenerator.schema.createDefaultObject function. The first parameter can be a base object.

Example with a generated ID:

1
let newModel = VueFormGenerator.schema.createDefaultObject(schema, {
2
id: getNextID(),
3
created: new Date().valueOf()
4
});
Copied!
Result:
1
{
2
"id": 6,
3
"type": "personal",
4
"created": 1462972235132,
5
"status": true
6
}
Copied!
Note: type and status field have default values in the schema.
Last modified 3yr ago