Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

SubmitUser Msg is never called and I can't quite figure out how to set it as the submit action #27

Closed
tolgap opened this issue May 22, 2016 · 2 comments

Comments

@tolgap
Copy link

tolgap commented May 22, 2016

In Elm 0.16, you'd write this code in the submit event of a button for a form:

let
  submitClick =
    case Form.getOutput form of
      Just user ->
        onClick address (SubmitUser user)
      Nothing ->
        onClick formAddress Form.Submit

So you can call the SubmitUser message to your application once your form has actual output without validation errors.

In 0.17, all Html types now have an Msg attributed to them. This causes the above case statement in the let binding to produce two different types, because one produces Html MyApp.Msg and the other Html Form.Msg.

I noticed the example app in tag 3.0.0 does not even use SubmitUser. But now, I'm trying to update my own app, and I run into this issue.

How would I port that let binding I posted above to 0.17?

@etaque
Copy link
Owner

etaque commented May 23, 2016

Hello,
Yes I should update example to show how to do that. Meanwhile, see this issue: https://github.com/etaque/elm-simple-form/issues/15

You can pattern match on Form action and Form.targetValue, if you got Submit and Just ... then you can proceed form result, or else call Form.update as before.

Does it make sense?

@tolgap
Copy link
Author

tolgap commented May 23, 2016

Hi @etaque , that makes sense. Didn't realize issue 15 was for this matter (couldn't make it up from the title). Thanks for the response!

@tolgap tolgap closed this as completed May 23, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants