diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index c4d9a4149..b36f0998e 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -119,7 +119,9 @@ const defaultButtons = computed(() => ({ color: 'primary', icon: 'save', label: 'globals.save', - click: async () => await save(), + click: async () => { + submitForm(); + }, type: 'submit', }, reset: { @@ -132,6 +134,14 @@ const defaultButtons = computed(() => ({ ...$props.defaultButtons, })); +const submitForm = () => { + myForm.value.validate().then((success) => { + if (success) { + save(); + } + }); +}; + onMounted(async () => { nextTick(() => (componentIsRendered.value = true)); @@ -312,6 +322,7 @@ async function onKeyup(evt) { } defineExpose({ + myForm, save, isLoading, hasChanges, @@ -325,7 +336,7 @@ defineExpose({ { const onClick = async (saveAndContinue) => { isSaveAndContinue.value = saveAndContinue; - await formModelRef.value.save(); + formModelRef.value.myForm.submit(); }; defineExpose({ @@ -61,6 +61,7 @@ defineExpose({ :default-actions="false" v-bind="$attrs" @on-data-saved="onDataSaved" + @submit.prevent >