storyfeet
storyfeet

Reputation: 145

Elm Lang read form data at point of onSubmit

I'm trying to make a web page in elm with several forms on. Different forms will show at different times.

I want to read the data from the onSubmit (Command/Message) into a method.

Everyting I can find seems to say I need to have a message for each for change to the form as users type, so if I have a form with 20 data points I need a separate message to record each change.

I find this odd, surely the onSubmit can pickup the form data and return it as a part of the message I wish to work with. Otherwise I have to have soo many separate messages each to handle and do the exact same thing, carefully named to avoid collisions.

Is there something I'm missing?

Thanks

Matt

Upvotes: 1

Views: 63

Answers (1)

bdukes
bdukes

Reputation: 155935

It's probably technically possible to get all of that information via the form submission (though it would probably be fragile). However, the way that Elm works best would have you storing that data in your model and updating it incrementally as the form is filled out with many explicit messages. The Elm community generally values being explicit over reducing boilerplate. So, no, you're not missing something.

Upvotes: 2

Related Questions