Merge pull request #1544 from nmk/master

Do not lose selected value in `selectFieldHelper` when validation fails
This commit is contained in:
Michael Snoyman 2018-07-29 10:21:35 +03:00 committed by GitHub
commit 6f76b5ff91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -1,5 +1,10 @@
# ChangeLog for yesod-form
## Unreleased
* make sure a select field does not lose the selected value even if a validation on the
field fails
## 1.6.2
* Move `addClass` from private/undocumented in `Yesod.Form.Bootstrap3` to `Yesod.Form.Functions` [#1510](https://github.com/yesodweb/yesod/pull/1510)

View File

@ -759,7 +759,7 @@ selectFieldHelper outside onOpt inside opts' = Field
, fieldEnctype = UrlEncoded
}
where
render _ (Left _) = ""
render _ (Left x) = x
render opts (Right a) = maybe "" optionExternalValue $ listToMaybe $ filter ((== a) . optionInternalValue) opts
selectParser _ [] = Right Nothing
selectParser opts (s:_) = case s of