aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/app/Form
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2024-06-04 09:59:10 +0200
committerLibravatar Alexander Foremny <aforemny@posteo.de>2024-06-04 09:59:10 +0200
commit9d3c32956baab4dc4e1fd114e586b48d850a14c9 (patch)
treed0de8ff50ffe9bfaeeebc58fbca9a76157614fef /frontend/app/Form
parent342ebdf61b3b9021b9e58cfce607e96a6e7ae54e (diff)
show form input
Diffstat (limited to 'frontend/app/Form')
-rw-r--r--frontend/app/Form/Input.hs5
-rw-r--r--frontend/app/Form/Internal.hs9
2 files changed, 7 insertions, 7 deletions
diff --git a/frontend/app/Form/Input.hs b/frontend/app/Form/Input.hs
index a9648c4..4b1eac8 100644
--- a/frontend/app/Form/Input.hs
+++ b/frontend/app/Form/Input.hs
@@ -6,7 +6,7 @@ where
import Data.Text qualified as T
import Form.Internal
import Miso
-import Miso.String (toMisoString)
+import Miso.String (fromMisoString, toMisoString)
string :: String -> Form T.Text T.Text
string label =
@@ -17,7 +17,8 @@ string label =
[ text (toMisoString label),
input_
[ type_ "text",
- value_ (toMisoString i)
+ value_ (toMisoString i),
+ onInput fromMisoString
]
]
]
diff --git a/frontend/app/Form/Internal.hs b/frontend/app/Form/Internal.hs
index 7782368..8c9935f 100644
--- a/frontend/app/Form/Internal.hs
+++ b/frontend/app/Form/Internal.hs
@@ -53,8 +53,7 @@ mapValues get set (Form {view, fill}) =
}
runForm :: Form i o -> i -> View (Either i o)
-runForm (Form {view}) i =
- div_ [] $
- (fmap Left <$> view i)
- <> [ button_ [type_ "submit"] [text "submit"]
- ]
+runForm form i =
+ form_ [onSubmit (either (\_ -> Left i) (Right) (form.fill i))] $
+ (fmap Left <$> form.view i)
+ <> [button_ [type_ "submit"] [text "submit"]]