diff --git a/yesod-form/Yesod/Form/Functions.hs b/yesod-form/Yesod/Form/Functions.hs index fc1e9903..73e26060 100644 --- a/yesod-form/Yesod/Form/Functions.hs +++ b/yesod-form/Yesod/Form/Functions.hs @@ -62,7 +62,7 @@ import Yesod.Core import Yesod.Core.Handler (defaultCsrfParamName) import Network.Wai (requestMethod) import Text.Hamlet (shamlet) -import Data.Monoid (mempty) +import Data.Monoid (mempty, (<>)) import Data.Maybe (listToMaybe, fromMaybe) import qualified Data.Map as Map import qualified Data.Text.Encoding as TE @@ -336,13 +336,13 @@ identifyForm identVal form = \fragment -> do -- Create hidden . let fragment' = [shamlet| - + #{fragment} |] -- Check if we got its value back. mp <- askParams - let missing = (mp >>= Map.lookup identifyFormKey) /= Just [identVal] + let missing = (mp >>= Map.lookup identifyFormKey) /= Just ["identify-" <> identVal] -- Run the form proper (with our hidden ). If the -- data is missing, then do not provide any params to the @@ -350,7 +350,10 @@ identifyForm identVal form = \fragment -> do -- doing this avoids having lots of fields with red errors. let eraseParams | missing = local (\(_, h, l) -> (Nothing, h, l)) | otherwise = id - eraseParams (form fragment') + ( res', w) <- eraseParams (form fragment') + + let res = if missing then FormMissing else res' + return ( res, w) identifyFormKey :: Text identifyFormKey = "_formid"