(no title)
throwaway60320 | 2 years ago
What about complex validation rules? Do you really think it's user friendly to require them to send the whole form just to tell them "sorry no" 10 times over until they get it right?
What about multi-value selects, potentially with rules? E.g. form field like "choose up to 5 locations in the radius of 10km".
What about form fields like "pick a point on a map"?
Etc. Don't act like every form is 5 simple text inputs.
rmbyrro|2 years ago
You'll have to do in the server, if you're sane.
I bet Retool Forms does in the server.
You're worried the page will refresh with an empty form, if it fails. It's simple, just collect the data and return the form pre-filled using the value attribute, along with the error message.
If you don't want to refresh the page, you could even use something like htmx, which is a LOT simpler than React, but really not necessary for simple form submission.
throwaway60320|2 years ago
But you want to provide better UX to the user.
Htmx is not simpler than React. I can't deploy that without a server that knows everything about the frontend. React allows me to decouple. Templates are hell. I lived in it for many years, never again.
hk__2|2 years ago
Well to be honest 99% of forms are 5 simple text inputs with a select. What was the last time you had to implement a "choose up to 5 locations in the radius of 10km", really?
> What about form fields like "pick a point on a map"?
Same thing: of course there are rich forms for which you need JS, but they are the exception, not the rule.
_heimdall|2 years ago
Doing form validation in event handlers for DOM events works very well, and a simple script tag or custom element is all that's needed to build a multi-value select.
throwaway60320|2 years ago
I really don't want to go back to the jQuery days. You do you, but don't say it's easier - it really isn't.
BTW you can just use Preact if you're worried about the bundle size. I do that, it's perfect and just a little performance impact, usually not visible in small apps.
cabalamat|2 years ago
I wpould use my server-side form and database library, Bozen[1] to do this.
>
[1]: https://github.com/cabalamat/frambozenapp
throwaway60320|2 years ago