# Handling submit
When a form is submitted, some action needs to take place in order for the code to know that it should do something with the data.
# Form submission
To handle form submission, first define a submit function (can be named anything) in the methods
section of the component. On the button set the bind to the click
event and set the value to the method created:
<template>
<form v-form="myForm">
<!-- omitted -->
<!-- needed for submission -->
<button @click="submit">Submit</button>
</form>
</template>
<script>
export default {
name 'MyForm',
data() {
return {
myForm: this.$createForm(),
myFormData: { /** omitted **/}
}
},
mounted() {
this.myForm
.setValidations(/** omitted **/)
.init();
},
methods: {
submit() {
// check form data
console.log('my data', this.myFormData);
}
}
}
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Clearing form
If there is a need to clear the form at any point in time you can do so by calling:
// if the form object is myDataForm
this.myDataForm.clearForm();
1
2
2