fix submit form

This commit is contained in:
Alex Turchyn
2023-07-08 20:51:37 +03:00
parent 254aa9e950
commit dcbdc9e60c
4 changed files with 14 additions and 12 deletions
+10 -10
View File
@@ -21,12 +21,6 @@
name="authenticity_token"
:value="authenticityToken"
>
<input
v-if="currentStep === stepFields.length - 1"
type="hidden"
name="completed"
value="true"
>
<input
value="put"
name="_method"
@@ -263,7 +257,7 @@
href="#"
class="inline border border-base-300 h-3 w-3 rounded-full mx-1"
:class="{ 'bg-base-300': index === currentStep, 'bg-base-content': index < currentStep || isCompleted, 'bg-white': index > currentStep }"
@click.prevent="isCompleted ? '' : goToStep(step, true)"
@click.prevent="isCompleted ? '' : [saveStep(), goToStep(step, true)]"
/>
</div>
</div>
@@ -401,13 +395,13 @@ export default {
}
})
},
saveStep () {
saveStep (formData) {
if (this.isCompleted) {
return Promise.resolve({})
} else {
return fetch(this.submitPath, {
method: 'POST',
body: new FormData(this.$refs.form)
body: formData || new FormData(this.$refs.form)
})
}
},
@@ -420,7 +414,13 @@ export default {
await stepPromise()
this.saveStep().then(response => {
const formData = new FormData(this.$refs.form)
if (this.currentStep === this.stepFields.length - 1) {
formData.append('completed', 'true')
}
this.saveStep(formData).then(response => {
const nextStep = this.stepFields[this.currentStep + 1]
if (nextStep) {