The View Model is used for start-form and user-task forms scenarios. When CamundaTask is not null the form is a user-task form, otherwise it is a start-form.
Copy data class Address (
val street: String ,
val houseNumber: String ,
val zipCode: String
)
data class Person (
val firstName: String ,
val lastName: String ,
val fullName: String = "$firstName $lastName" ,
val age: Int ,
var personalAddress: Address ? = null
) : ViewModel {
override fun update (submission: T , task: CamundaTask ?, businessKey: String ): ViewModel {
// code to update the ViewModel
return this
}
}
Copy {
"firstName" : "John" ,
"lastName" : "Doe" ,
"fullName" : "John Doe" ,
"age" : 25 ,
"personalAddress" : {
"street" : "Main Street" ,
"houseNumber" : "123" ,
"zipCode" : "12345"
}
}
Copy {
"display" : "form" ,
"settings" : {
"pdf" : {
"id" : "1ec0f8ee-6685-5d98-a847-26f67b67d6f0" ,
"src" : "https://files.form.io/pdf/5692b91fd1028f01000407e3/file/1ec0f8ee-6685-5d98-a847-26f67b67d6f0"
}
} ,
"components" : [
{
"label" : "Firstname" ,
"key" : "firstName" ,
"type" : "textfield" ,
"input" : true
} ,
{
"label" : "Lastname" ,
"key" : "lastName" ,
"type" : "textfield" ,
"input" : true
} ,
{
"label" : "Fullname" ,
"key" : "fullName" ,
"type" : "textfield" ,
"input" : true
} ,
{
"label" : "Age" ,
"key" : "age" ,
"type" : "textfield" ,
"input" : true
} ,
{
"label" : "Container" ,
"tableView" : false ,
"key" : "personalAddress" ,
"type" : "container" ,
"input" : true ,
"components" : [
{
"label" : "Street" ,
"applyMaskOn" : "change" ,
"tableView" : true ,
"key" : "street" ,
"type" : "textfield" ,
"input" : true
} ,
{
"label" : "HouseNumber" ,
"applyMaskOn" : "change" ,
"tableView" : true ,
"key" : "houseNumber" ,
"type" : "textfield" ,
"input" : true
} ,
{
"label" : "ZipCode" ,
"applyMaskOn" : "change" ,
"tableView" : true ,
"key" : "zipCode" ,
"type" : "textfield" ,
"input" : true
}
]
} ,
{
"type" : "button" ,
"label" : "Submit" ,
"key" : "submit" ,
"disableOnInvalid" : true ,
"input" : true
}
]
}
The ViewModel list of fields is compared to the FormDefinition list of fields.
Copy The following properties are missing in the view model for form (user-task-2): [age,...]
Copy The following properties are missing in the submission for form (user-task-2): [age,...]