Reputation: 2970
I have a dynamic form using VueJs form generator, using simple button like textBox or text area I update an array of model and array of schema, and use it like this,
var fromControlRules = new Vue({
el: '#form',
components: {
"vue-form-generator": VueFormGenerator.component
},
data() {
return {
model: {
model: formModel (//array of model)
},
schema: {
fields: formSchema (//array of schema)
},
formOptions: {
validateAfterLoad: true,
validateAfterChanged: true
}
}
},
'formSchema' is like this,
formSchema = [
{
type: "input",
inputType: "text",
label: "Name of the field",
model: "name"
},
{
type: "input",
inputType: "text",
label: "Type of the field",
model: "type"
}];
On submit or cancel of the modal form, I want to clear the model, but doesn't happen when I see the form the fields are still there. Let me know how I can reset the form, so probably I can create a new form, this time maybe with date fields and dropdowns instead of text boxes.
Upvotes: 1
Views: 834
Reputation: 809
UPD: you don't need to use Vue.set
, try this instead:
formSchema.splice(0, formSchema.length)
Upvotes: 1