From 2fed28af90644df75f411eb6e7ae3d620980ad24 Mon Sep 17 00:00:00 2001 From: Dario Oddenino Date: Fri, 5 Jun 2020 12:03:40 +0200 Subject: [PATCH] Update readme.md Some fixes in the code examples --- readme.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/readme.md b/readme.md index 2fbfb7e..612212d 100644 --- a/readme.md +++ b/readme.md @@ -310,23 +310,26 @@ Also note how we fetch and display the error messages associated with each field ```purescript renderFormWidget :: UserFormState -> Widget HTML (Query UserForm) renderFormWidget st = do - query <- D.div' + D.div' [ D.input - [ P.value $ F.getInput _name fstate.form + [ P.value $ F.getInput _name st.form , (F.set _name <<< P.unsafeTargetValue) <$> P.onChange ] - , errorDisplay $ F.getError _name fstate.form + , errorDisplay $ F.getError _name st.form , D.input - [ P.value $ F.getInput _email1 fstate.form + [ P.value $ F.getInput _email1 st.form -- This will help us avoid hitting the server on every single key press. , (F.asyncSetValidate debounceTime _email1 <<< P.unsafeTargetValue) <$> P.onChange ] - , errorDisplay $ F.getError _email1 fstate.form + , errorDisplay $ F.getError _email1 st.form , D.input - [ P.value $ F.getInput _email2 fstate.form + [ P.value $ F.getInput _email2 st.form , (F.asyncSetValidate debounceTime _email2 <<< P.unsafeTargetValue) <$> P.onChange ] - , errorDisplay $ F.getError _email2 fstate.form + , errorDisplay $ F.getError _email2 st.form + , D.button + [ F.submit <$ P.onClick ] + [ D.text "Submit" ] ] where _name = SProxy :: SProxy "name" @@ -403,7 +406,7 @@ page :: Widget HTML Unit page = do user <- D.div' [ D.h1' [D.text "Contact Form"] - , formWidget (initState initialInputs validators) + , formWidget (F.initFormState initialInputs validators) ] liftEffect $ Console.log $ "Got a user! " <> show (user :: User) ```