Fable.Form allows you to build forms that are:
Msg
for each field neither repeat your view
codelet form : Form.Form<Values, Msg, _> =
let emailField =
Form.textField
{
Parser =
fun value ->
if value.Contains("@") then
Ok value
else
Error "The e-mail address must contain a '@' symbol"
Value =
fun values -> values.Email
Update =
fun newValue values ->
{ values with Email = newValue }
Error =
fun _ -> None
Attributes =
{
Label = "Email"
Placeholder = "some@email.com"
HtmlAttributes = [ ]
}
}
let passwordField =
Form.passwordField
{
// ...
}
let onSubmit =
fun email password ->
LogIn (email, password)
Form.succeed onSubmit
|> Form.append emailField
|> Form.append passwordField