Skip to content

setField

The setField function is used to set the value of a field. By default it will validate the value of the field, but you can disable the validation by passing false as the third argument.

Example

<script lang="ts">
import { onMount } from 'svelte';
import { faivform } from '@tuentyfaiv/svelte-form';
const form = faivform<Data>({
// ...config
});
const { setField } = $form;
onMount(async () => {
const response = await fetch('https://api.example.com/user');
const data = await response.json();
setField('name', data.name);
});
</script>