diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index 57456ba3d..f8e16be53 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -128,9 +128,7 @@ const defaultButtons = computed(() => ({ color: 'primary', icon: 'save', label: 'globals.save', - click: async () => { - submitForm(); - }, + click: async (evt) => submitForm(evt), type: 'submit', }, reset: { @@ -143,14 +141,10 @@ const defaultButtons = computed(() => ({ ...$props.defaultButtons, })); -const submitForm = async () => { +const submitForm = async (evt) => { const isFormValid = await myForm.value.validate(); if (isFormValid) { - try { - await save(); - } catch (error) { - app.config.errorHandler(error); - } + await save(evt); } }; @@ -328,11 +322,13 @@ async function onKeyup(evt) { selectionStart = selectionEnd = selectionStart + 1; return; } - await save(); + await submitForm(); } } defineExpose({ + submitForm, + myForm, save, isLoading, hasChanges, @@ -347,7 +343,7 @@ defineExpose({ ref="myForm" v-if="formData" @submit.prevent - @keyup.prevent="onKeyup" + @keyup="onKeyup" @reset="reset" class="q-pa-md" :style="maxWidth ? 'max-width: ' + maxWidth : ''" diff --git a/src/components/FormModelPopup.vue b/src/components/FormModelPopup.vue index b3370e2d1..48a3e77b6 100644 --- a/src/components/FormModelPopup.vue +++ b/src/components/FormModelPopup.vue @@ -43,6 +43,9 @@ const onDataSaved = async (formData, requestResponse) => { const onClick = async (saveAndContinue) => { isSaveAndContinue.value = saveAndContinue; + if (formModelRef.value) { + await formModelRef.value.submitForm(); + } }; defineExpose({ @@ -58,6 +61,7 @@ defineExpose({ ref="formModelRef" :observe-form-changes="false" :default-actions="false" + @submit="onClick" v-bind="$attrs" @on-data-saved="onDataSaved" @submit.prevent @@ -87,7 +91,6 @@ defineExpose({ :flat="showSaveAndContinueBtn" :label="t('globals.save')" :title="t('globals.save')" - @click="onClick(false)" type="submit" color="primary" class="q-ml-sm"