Tracks form state data using the vue composition api (vue 3)
Example usage:
export default {
setup() {
const formState = reactive(new FormState());
onMounted(async () => {
const initialData = await someApiCall();
formState.init(initialData);
});
const onSubmit = async () => {
formState.submit();
// Do stuff
formState.init(formState.formVals);
};
const onReset = () => {
formState.reset();
};
return { formState, onSubmit, onReset };
},
};
Use formState.formVals
to access your data in the template. The following computed properties can be used the the template as well:
formState.disabled
formState.submitted
formState.submittable