Skip to content

submit

The submit function is usefull to submit the form. It’s a higher order function that receives an action and a config object and return a Submit. The action is a function that receives the form data and returns a promise. The config object is an object that contains the options to submit the form.

Example

<script lang="ts">
import { faviform } from '@tuentyfaiv/svelte-form';
const form = faviform<Data>({
// ...config
});
const { submit } = $form;
const onSubmit = submit(async (data) => {
// ...submit logic
});
</script>
<form on:submit|preventDefault={onSubmit}>
<!-- ...fields -->
<button type="submit">Submit</button>
</form>