-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Hello again :),
Would it be possible to add a method to the form store to set it as dirty (set all its fields as dirty) in order for example to display all invalid fields at the same time when clicking on submit?
For now, this is a way of doing it :
<script lang="ts">
const fields: HTMLElement[] = [];
const invalidate = () => fields.forEach((field) => {
field.focus();
field.blur();
});
const onSubmit = () => {
if (!$form.valid) return invalidate();
/*... */
};
</script>
<form use:form on:submit|preventDefault={onSubmit}>
<input type="text" use:forename bind:this={fields[0]} />
<input type="text" use:surname bind:this={fields[1]} />
</form>
Metadata
Metadata
Assignees
Labels
No labels