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?
Asked
Active
Viewed 196 times
1
-
I would add an hiddenfield to your form. The value from this contains the action you want do to. – Reporter Jul 30 '21 at 08:09
1 Answers
1
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

Khairul Habib
- 452
- 1
- 12
- 29