Files
Website/resources/js/components/SMForm.vue
2023-04-25 19:24:20 +10:00

43 lines
893 B
Vue

<template>
<form class="SMForm" @submit.prevent="handleSubmit">
<!-- <SMMessage
v-if="props.modelValue._message.length > 0"
:message="props.modelValue._message"
:type="props.modelValue._messageType"
:icon="props.modelValue._messageIcon" /> -->
<slot></slot>
</form>
</template>
<script setup lang="ts">
import { provide } from "vue";
const props = defineProps({
modelValue: {
type: Object,
required: true,
},
});
const emits = defineEmits(["submit", "failedValidation"]);
/**
* Handle the user submitting the form.
*/
const handleSubmit = async function () {
if (await props.modelValue.validate()) {
emits("submit");
} else {
emits("failedValidation");
}
};
provide("form", props.modelValue);
</script>
<style lang="scss">
.SMForm {
width: 100%;
}
</style>