Hi, my quest for building my rather complicated form is almost over, I still have a couple things to figure out but it works like a charm and I loved the experience of building it!
https://github.com/etaque/elm-form proved to be very useful and well done, even if the lack of documentation doesn’t make me very confident I’m doing things right.
Now I have the form fully validated and I need to add the last validation that works by making an HTTP request to the server. I “kinda” did it, but I’m unhappy with my work.
Here is my update, sorry if it’s a bit long but I need to show it to make a point:
As you can see I try to use Form.Msg as much as possible, I don’t know if it’s right but it scopes the “form stuff” inside the Form, so for example to show/hide the password I simulate a Checkbox. For email uniqueness, I trigger an HTTP request when the email field doesn’t have validation errors, which is pretty good.
What I’d love to have is the ability to set an error inside the form itself instead of having that ugly emailTaken inside my model, but I really have no idea how to do it. Plus, the example in elm-form is very different most probably because it’s not really doing an HTTP call https://github.com/etaque/elm-form/blob/master/example/src/Model.elm#L163-L168
My question is, has anybody managed to do what I want to do with elm-form? I’m still quite new so even though my solution “works” I don’t like to have the form validation outside the form, but I don’t know how to handle this, maybe instead of setting emailTaken I should send a message to the form? Quite confusing.
I guess there’s a way to have a Form.Msg as second argument to Http.send, but then how do I manage the Http.Request as a form field? I’m lost.
Thanks in advance, ngw