Created
January 20, 2018 19:31
-
-
Save ericbmerritt/727b82d490408aa5132615139e84f46f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://git.gnu.io/chreekat/yesod/commit/41faf62094ad7077573de797599c742ff9401c4e | |
> mkYesod "HW" [$parseRoutes| | |
> / RootR GET | |
> /form FormR | |
> /static StaticR Static hwStatic | |
> /autocomplete AutoCompleteR GET | |
---- | |
handleFormR = do | |
> (res, form, enctype, nonce) <- runFormPost $ fieldsToTable $ (,,,,,,,,) | |
> <$> stringField "My Field" Nothing | |
> <*> stringField "Another field" (Just "some default text") | |
> <*> intField "A number field" (Just 5) | |
> <*> jqueryDayField def "A day field" Nothing | |
> <*> timeField "A time field" Nothing | |
> <*> boolField "A checkbox" (Just False) | |
> <*> jqueryAutocompleteField AutoCompleteR "Autocomplete" Nothing | |
> <*> nicHtmlField "HTML" | |
> (Just $ string "You can put <rich text> here") | |
> <*> maybeEmailField "An e-mail addres" Nothing | |
> let mhtml = case res of | |
> FormSuccess (_, _, _, _, _, _, _, x, _) -> Just x | |
> _ -> Nothing | |
> defaultLayout $ do | |
> addCassius [$cassius| | |
> .tooltip | |
---- | |
> getAutoCompleteR :: Handler RepJson | |
> getAutoCompleteR = do | |
> term <- runFormGet' $ stringInput "term" | |
> jsonToRepJson $ jsonList | |
> [ jsonScalar $ unpack term ++ "foo" | |
> , jsonScalar $ unpack term ++ "bar" | |
> , jsonScalar $ unpack term ++ "baz" | |
> ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment