Reputation: 31
I wrote a form with vue.js. This form has a submit button. I want to make the first record with this button and then update the information if the user requests it. Is this possible with the same button?
Upvotes: 1
Views: 266
Reputation: 471
i suggest you to compare the ID of your required info, as example:
onButtonClick(formValue) {
if (this.info.id) {
this.update(this.info.id, formValue);
} else {
this.create(formValue);
}
}
in this logic you can says if you start with empty form without any record, the this.info.id will be null and will triggered your create function. if there's record before you start alter the form it will trigger update function
Upvotes: 1