It seems like the issue is with the JavaScript code that handles the form submission. The code is not properly redirecting the user to the desired page after the form is submitted.
Here's a possible solution:
<template>
<form @submit.prevent="submitForm">
<!-- form fields here -->
<button type="submit" name="action" value="save">Save</button>
<button type="submit" name="action" value="submit">Submit</button>
</form>
</template>
<script>
export default {
methods: {
submitForm(event) {
const form = event.target;
const action = form.elements.action.value;
const formData = new FormData(form);
// make the API call to submit the form data
this.$http.post('/api/submit-form', formData)
.then(response => {
if (response.data.success) {
// redirect the user to the appropriate page
if (action === 'save') {
this.$router.push('/save-page');
} else if (action === 'submit') {
this.$router.push('/submit-page');
}
} else {
// handle error case
}
})
.catch(error => {
// handle error case
});
}
}
};
</script>
In this solution, we use a single form with two submit buttons, each with a different value for the name attribute. When the form is submitted, we extract the value of the action parameter from the form data and use it to determine which page to redirect the user to after the form is successfully submitted.
We also use the FormData API to serialize the form data and send it to the server using the this.$http.post method provided by Vue Resource. If the API call is successful, we redirect the user to the appropriate page using this.$router.push. If there is an error, we handle it appropriately.
Note that this solution assumes that you have set up Vue Router and Vue Resource correctly in your project. If you haven't, you'll need to do that first before this solution will work.