SolidStart render page from POST function
I have a form in
SolidStart
with method="post"
and action=""
.
To validate the form on server side, I export a POST
function.
However I am wondering how I could, if the data I got isn't valid, show the form again with the data the user already submitted (and maybe additional error messages) from this POST
function?9 Replies
So I think the basic question here is how to render a page from a POST function
Did you check this page in the doc?
https://start.solidjs.com/core-concepts/actions
SolidStart Beta Docuentation
SolidStart Beta Documentation
Early release documentation and resources for SolidStart Beta
Yep, I read it.
The problem is stated here: https://github.com/solidjs/solid-start/discussions/548
GitHub
How to properly handle errors in form? · Discussion #548 · solidjs/...
Hi, I'd like to handle field errors when submitting a form using createServerAction$. I understand I can throw a ResponseError but I can't find in the doc how to use it. The ultimat...
Oh ok, I don't know if you know about https://felte.dev/ but, I ended up using it for my project, which is heavy on forms. What I basically did was create a component for each field ; they take as props
errors
, data
, setFields
, setErrors
, etc from Felte's Form helper. That way I can update the UI according my Zod validation rules, at the UI level. Then on the server (using a API route), I submit the form and I re-use my form Zod Schema (which is composed of field-level schema) to validate the form globally, and process the values.Felte | Home
An extensible form library for Svelte, Solid and React.
Maybe that's not really crystal clear, but I really found Felte to intuitive. And I ended up with complex forms quite easily.
Sounds good to me basically, but it lacks no-js support, I think?
Yeah, that's right. In my context, this is not an issue.
👍 Yes, I'd like my site to work good without JS enabled, so I have to search a solution...