Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting initial error state for a form field #217

Open
frenzzy opened this issue Jun 20, 2024 · 1 comment
Open

Setting initial error state for a form field #217

frenzzy opened this issue Jun 20, 2024 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@frenzzy
Copy link

frenzzy commented Jun 20, 2024

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
Copy link
Owner

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

@fabian-hiller fabian-hiller self-assigned this Jun 20, 2024
@fabian-hiller fabian-hiller added the question Further information is requested label Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants