2
我想在同一個處理程序中呈現2個不同形式,但我不確定是否可能。在同一個處理程序中呈現多個表單yesod
的形式是:
questionForm :: ExamId -> AForm Handler Question
questionForm eid = Question
<$> areq textField (bfs (MsgQuestion)) Nothing
<*> pure eid
answerQuestionForm :: QuestionId -> AForm Handler UserAnswer
answerQuestionForm qid = UserAnswer
<$> areq textField (bfs (MsgAnswer)) Nothing
<*> pure Nothing
<*> pure qid
我打算用這個GET方法
getAnswerQuestionR :: ExamId -> Handler Html
getAnswerQuestionR eid = do
mid <- maybeAuthId
questions <- runDB $ selectList [] [Desc QuestionQuestionText]
(articleWidget, enctype) <- generateFormPost $ renderBootstrap3 BootstrapBasicForm $ questionForm eid
defaultLayout $ do
$(widgetFile "TakeExam/answerQuestion")
getAnswerQuestionPR :: QuestionId -> Handler Html
getAnswerQuestionPR qid = do
uid <- requireAuthId
(widget, encoding) <- generateFormPost $ renderBootstrap3 BootstrapBasicForm $ answerQuestionForm qid
defaultLayout $ do
let actionR = ExamR
$(widgetFile "TakeExam/answerQuestion")
但這個選項不能正常工作
究竟是什麼「不工作」?你在編譯時遇到錯誤嗎?在運行時?正確運行哪個命令?什麼輸出? – d8d0d65b3f7cf42 2015-04-03 18:36:13
是的我在編譯時出錯:Handler/TakeExam.hs:32:23: 不在範圍內:'questions' 在splice中:$(widgetFile「TakeExam/answerQuestion」) – oriaj 2015-04-03 22:59:10