packages feed

yesod-form 1.4.9 → 1.4.10

raw patch · 3 files changed

+13/−5 lines, 3 files

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+## 1.4.10++* Fixed `identifyForm` to properly return `FormMissing` for empty forms. [#1072](https://github.com/yesodweb/yesod/issues/1072)+ ## 1.4.9  * Added a `ToValue` instance for `Enctype` [#1296](https://github.com/yesodweb/yesod/pull/1296)
Yesod/Form/Functions.hs view
@@ -62,7 +62,7 @@ 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 @@     -- Create hidden <input>.     let fragment' =           [shamlet|-            <input type=hidden name=#{identifyFormKey} value=#{identVal}>+            <input type=hidden name=#{identifyFormKey} value=identify-#{identVal}>             #{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 <input>).  If the     -- data is missing, then do not provide any params to the@@ -350,7 +350,11 @@     -- 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')++    -- Empty forms now properly return FormMissing. [#1072](https://github.com/yesodweb/yesod/issues/1072)+    let res = if missing then FormMissing else res'+    return ( res, w)  identifyFormKey :: Text identifyFormKey = "_formid"
yesod-form.cabal view
@@ -1,5 +1,5 @@ name:            yesod-form-version:         1.4.9+version:         1.4.10 license:         MIT license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>