我有一个简单且不完整的 Happstack 应用程序,它包含一个消化函子形式,定义如下:
setRecFormSpec :: Monad m => Form Text m Reminder
setRecFormSpec = Reminder
<$> "progname" .: string Nothing
<*> "channel" .: string Nothing
<*> "when" .: localTimeFormlet "%d/%m/%Y" "%H:%M" Nothing
<*> "recordLimit" .: stringRead "Can't parse number" (Just 7)
其视图定义如下:
setRecView :: View H.Html -> H.Html
setRecView view = do
H.div ! A.class_ "container" $ do
H.h1 "Set Record Reminder"
childErrorList "" view
divFormGroup $ do
label "progname" view "Program Name:"
formControl $ inputText "progname" view
divFormGroup $ do
label "channel" view "Channel:"
formControl $ inputText "channel" view
divFormGroup $ do
label "when" view "When:"
formControl $ inputDate "when" view
divFormGroup $ do
label "recordLimit" view "Recording Limit (days):"
formControl $ inputText "recordLimit" view
divFormGroup $ do
formControl $ inputSubmit "Signup"
-- divFormGroup -- candidate to go into a Bootstrap library
divFormGroup :: H.Html -> H.Html
divFormGroup h =
H.div ! A.class_ "form-group" $ h
-- formControl -- candidate to go into a Bootstrap library
formControl :: H.Html -> H.Html
formControl h = (h ! A.class_ "form-control")
提醒定义如下:
data Reminder = Reminder {
programName :: String -- ^ name of program
, channel :: String -- ^ name of broadcast channel
, firstShowing :: LocalTime -- ^ time of first showing
, timerPeriodDays :: Integer -- ^ how far in advance we can set timer, in days
} deriving (Show)
当我浏览到表单 (/setrec) 的路径时,我得到一个空白页,控制台上打印了以下错误消息:
HTTP request failed with: when is not a field
我发现该错误消息的定义位置(在https://github.com/jaspervdj/digestive-functors/blob/7e50d5686abc4b39389ed195693660d758987c7c/digestive-functors/src/Text/Digestive/Form/Internal.hs中)但我可以从那里看不到为什么找不到“何时”字段。
这里有什么问题?
如何调试此类问题?
这是github上整个代码的链接,以防您需要更深入地查看代码: