fabian-hiller / modular-forms

The modular and type-safe form library for SolidJS, Qwik and Preact
https://modularforms.dev
MIT License
995 stars 53 forks source link

Setting initial error state for a form field #217

Open frenzzy opened 3 months ago

frenzzy commented 3 months ago

Modular Forms provides the ability to specify initial form field values via the FormOptions object: initialValues.

I need the ability to set the initial state of a specific field as an error.

Imagine a scenario where I redirect to a form that verifies uniqueness on the server, and I need to render the form with one field marked as not unique.

What is the right way to achieve this:

  1. Should Modular Forms support FormOptions.initialErrors?
  2. Should users use setError and setResponse? Would be nice to see an example code snippet in the docs (do I need to use batch() etc)
  3. Is there another recommended approach?
fabian-hiller commented 3 months ago

I think the only option we have at the moment is to use setError or setResponse.