我尝试关注 Michael Snoyman 的截屏视频http://vimeo.com/39646807。但是,似乎对 i18n 的更改会导致该代码失败。我在搭建的站点上找不到任何有关如何解决此问题的信息,而且我无法完全理解http://www.yesodweb.com/book/internationalization此处提供的信息。
这是我得到的错误,指的是 Home.hs 中的代码:
No instance for (RenderMessage master0 FormMessage)
arising from a use of `generateFormPost'
Possible fix:
add an instance declaration for (RenderMessage master0 FormMessage)
In a stmt of a 'do' block:
(formWidget, enctype) <- generateFormPost noteForm
In the expression:
do { (formWidget, enctype) <- generateFormPost noteForm;
defaultLayout ($(widgetFile "notes")) }
In an equation for `getNotesR':
getNotesR
= do { (formWidget, enctype) <- generateFormPost noteForm;
defaultLayout ($(widgetFile "notes")) }
信息似乎很清楚,问题是我不知道如何为(RenderMessage master0 FormMessage)添加实例声明。
这是我添加到 Home.hs 的代码
noteForm = renderBootstrap $ Note
<$> areq textField "Title" Nothing
<*> areq textField "Content" Nothing
getNotesR = do
(formWidget, enctype) <- generateFormPost noteForm
defaultLayout $(widgetFile "notes")
postNotesR = return ()
getNoteR noteId = return ()
Ant以下来自templates/notes.hamlet
<form method=post enctype=#{enctype}>
^{formWidget}
<input type=submit>