问题
I want to make an HTML form that actually uses the [form] tag in ELM. None of the example online do this -- they simply put the [input] tags in a [div] instead of a [form]
When I try switching my Elm app to a [form], my [input type=sumbit] tags don't seem to call back to Elm. The submit tries to leave the page and add a "?" to my url.
Any hints on how to do this?
WHY: I want to be a using [form], so I can use the "required" attribute on some [input] fields. This is just one part of my validation, but I like the UI that "required" tag presents.
回答1:
You should use onSubmit in Html.form.
Here is the example.
Html.form [ onSubmit Submit ]
[ input
[ type' "submit"
, value "click here to submit"
]
[]
]
来源:https://stackoverflow.com/questions/40311080/how-to-use-html-form-in-elm-form