diff --git a/src/Handler/Course.hs b/src/Handler/Course.hs index f4c791d49..819f64edc 100644 --- a/src/Handler/Course.hs +++ b/src/Handler/Course.hs @@ -233,8 +233,7 @@ courseToForm cEntity = CourseForm course = entityVal cEntity newCourseForm :: Maybe CourseForm -> Form CourseForm -newCourseForm template = -- identifyForm "newCourseForm" $ - \html -> do +newCourseForm template = identForm FIDcourse $ \html -> do -- mopt hiddenField -- cidKey <- getsYesod appCryptoIDKey -- courseId <- runMaybeT $ do diff --git a/src/Handler/Utils/Form.hs b/src/Handler/Utils/Form.hs index a619da262..89e34f284 100644 --- a/src/Handler/Utils/Form.hs +++ b/src/Handler/Utils/Form.hs @@ -24,6 +24,17 @@ import Yesod.Form.Bootstrap3 import Web.PathPieces (showToPathPiece, readFromPathPiece) +------------------------------------------------ +-- Unique Form Identifiers to avoid accidents -- +------------------------------------------------ + +data FormIdentifier = FIDcourse + deriving (Enum, Eq, Ord, Bounded, Read, Show) + + +identForm :: FormIdentifier -> Form a -> Form a +identForm fid = identifyForm (T.pack $ show fid) + ---------------------------- -- Buttons (new version ) --