mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-23 22:26:16 +03:00
Handle decoding events for form submissions with no buttons (no submitter).
This commit is contained in:
parent
e264ce3d07
commit
2a0c775462
@ -575,7 +575,6 @@ addItemForm =
|
|||||||
]
|
]
|
||||||
description
|
description
|
||||||
, formState.data |> Maybe.map (\error -> Html.div [ class "error", id "new-todo-error" ] [ text error ]) |> Maybe.withDefault (text "")
|
, formState.data |> Maybe.map (\error -> Html.div [ class "error", id "new-todo-error" ] [ text error ]) |> Maybe.withDefault (text "")
|
||||||
, Html.button [ style "display" "none" ] [ Html.text "Create" ]
|
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -600,7 +599,6 @@ editItemForm =
|
|||||||
, id ("todo-" ++ uuidToString formState.data.id)
|
, id ("todo-" ++ uuidToString formState.data.id)
|
||||||
]
|
]
|
||||||
description
|
description
|
||||||
, Html.button [ style "display" "none" ] []
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -27,13 +27,21 @@ formDataOnSubmit =
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(Decode.at [ "submitter", "form", "method" ] methodDecoder)
|
(currentForm "method" methodDecoder)
|
||||||
(Decode.at [ "submitter", "form", "action" ] Decode.string)
|
(currentForm "action" Decode.string)
|
||||||
(Decode.at [ "submitter", "form", "id" ] (Decode.nullable Decode.string))
|
(currentForm "id" (Decode.nullable Decode.string))
|
||||||
|> Decode.map alwaysPreventDefault
|
|> Decode.map alwaysPreventDefault
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
currentForm : String -> Decode.Decoder a -> Decode.Decoder a
|
||||||
|
currentForm field decoder_ =
|
||||||
|
Decode.oneOf
|
||||||
|
[ Decode.at [ "submitter", "form" ] decoder_
|
||||||
|
, Decode.at [ "currentTarget", field ] decoder_
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
methodDecoder : Decode.Decoder FormData.Method
|
methodDecoder : Decode.Decoder FormData.Method
|
||||||
methodDecoder =
|
methodDecoder =
|
||||||
Decode.string
|
Decode.string
|
||||||
|
Loading…
Reference in New Issue
Block a user