Remove hardcoded form id.

This commit is contained in:
Dillon Kearns 2022-07-24 10:02:06 +02:00
parent 0625ce0183
commit 6291237bf4
3 changed files with 6 additions and 6 deletions

View File

@ -203,7 +203,7 @@ view maybeUrl sharedModel model app =
pendingCreation : Result (Form.FieldErrors String) NewItem
pendingCreation =
form
|> Form.parse app app.data
|> Form.parse "form" app app.data
|> parseIgnoreErrors
in
{ title = "New Item"

View File

@ -315,7 +315,7 @@ view maybeUrl sharedModel model app =
pendingCreation : Maybe NewItem
pendingCreation =
form
|> Form.parse app app.data
|> Form.parse "form" app app.data
|> parseIgnoreErrors
|> Result.toMaybe
|> Maybe.andThen

View File

@ -665,11 +665,12 @@ mergeErrors errors1 errors2 =
{-| -}
parse :
AppContext app
String
-> AppContext app
-> data
-> Form error { info | combine : Validation error parsed named } data
-> ( Maybe parsed, FieldErrors error )
parse app data (FormNew _ parser _) =
parse formId app data (FormNew _ parser _) =
-- TODO Get transition context from `app` so you can check if the current form is being submitted
-- TODO either as a transition or a fetcher? Should be easy enough to check for the `id` on either of those?
let
@ -684,8 +685,7 @@ parse app data (FormNew _ parser _) =
thisFormState : Form.FormState
thisFormState =
app.pageFormState
-- TODO remove hardcoding
|> Dict.get "test"
|> Dict.get formId
|> Maybe.withDefault initFormState
in
{ result = ( parsed.parsedAndView.combine, parsed.result )