CaptainCodeman / svelte-form-helper

Lightweight helpers for form validation with Svelte
https://captaincodeman.github.io/svelte-form-helper/
MIT License
55 stars 0 forks source link

Create fields from form and support dynamic fields #2

Closed CaptainCodeman closed 1 year ago

CaptainCodeman commented 1 year ago

Avoids potential mismatch from passing fields into the form constructor (i.e. adding a field requires changes in two place)

const form = createForm()
const email = form.field()

The current constructor is still there for the time being but will likely be removed along with the option to create a field that isn't associated with a form (i.e.createField())

Also adds support for dynamic fields - only fields with HTML Input elements in the DOM contribute to the form validity state. So if the input of an email can be toggled, it won't prevent the form being submitted, but can require validation if present.