From 1b272c6ee89896de8d6d8071bb755a831c2d46cd Mon Sep 17 00:00:00 2001 From: SJost Date: Fri, 17 Nov 2017 16:59:48 +0100 Subject: [PATCH] Form-Identifiers introduced --- src/Handler/Course.hs | 3 +-- src/Handler/Utils/Form.hs | 11 +++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) 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 ) --