formValues

Description#

This store contains all the current form values at the time any value changes on a bound element. The values are an Object with the key per group name and it's value.

The value can be a single value, or an array or values depending on there being fields with the same name (e.g. multiple checkboxes), or a <select> element with the multiple attribute.

Example#

<script>
import {formula} from 'svelte-formula';
const {form, formValues} = formula();
$ total = ($formValues?.value1 || 0) + ($formValues?.value2 || 0)
});
</script>
<form use:form>
<label for='value-1'>Value 1</label>
<input type='number' required id='value-1' name='value1' />
<label for='value-2'>Value 2</label>
<input type='number' required id='value-2' name='value2' />
<div>{$formValues?.value1} + {$formValues?.value2} = {total}</div>
</form>