Below I have an example from the Yesod book. The form action maps to a route. How do I pass a value to that route. I know it has something to do with ^
but I can't see to make it work right.
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
import Control.Applicative
import Data.Text (Text)
import Yesod
data App = App
mkYesod "App" [parseRoutes|
/ HomeR GET
/input InputR GET
|]
instance Yesod App
instance RenderMessage App FormMessage where
renderMessage _ _ = defaultFormMessage
data Person = Person
{ personName :: Text
, personAge :: Int
}
deriving Show
getHomeR :: Handler Html
getHomeR = defaultLayout
[whamlet|
<form action=@{InputR}> <--- problem line -- want to do this <form action=@{InputR ^haskellValue}>
<p>
My name is
<input type=text name=name>
and I am
<input type=text name=age>
years old.
<input type=submit value="Introduce myself">
|]
getInputR :: Text -> Handler Html
getInputR label = do
person <- runInputGet $ Person
<$> ireq textField label
<*> ireq intField "age"
defaultLayout [whamlet|<p>#{show person}|]
main :: IO ()
main = warp 3000 App