diff --git a/yesod-form/ChangeLog.md b/yesod-form/ChangeLog.md index 7cbbf4518..3bd798ef6 100644 --- a/yesod-form/ChangeLog.md +++ b/yesod-form/ChangeLog.md @@ -1,6 +1,11 @@ # ChangeLog for yesod-form +## 1.7.8 + +* Added `radioField'` for creating radio button in more correct way than original `radioField`. + Function `radioField` marked as deprecated. [#1842](https://github.com/yesodweb/yesod/pull/1842) + ## 1.7.7 * Added `optionsFromList'` to create an OptionList from a List, using the PathPiece instance for the external value and diff --git a/yesod-form/Yesod/Form/Fields.hs b/yesod-form/Yesod/Form/Fields.hs index ab0067c7c..ab8583313 100644 --- a/yesod-form/Yesod/Form/Fields.hs +++ b/yesod-form/Yesod/Form/Fields.hs @@ -48,6 +48,7 @@ module Yesod.Form.Fields , selectFieldList , selectFieldListGrouped , radioField + , radioField' , radioFieldList , withRadioField , checkboxesField @@ -123,6 +124,8 @@ import Data.Monoid import Data.Char (isHexDigit) +{-# DEPRECATED radioField "This function seems to have a bug (label could not be found with byLabel algorithm)" #-} + defaultFormMessage :: FormMessage -> Text defaultFormMessage = englishFormMessage @@ -529,6 +532,7 @@ checkboxesField ioptlist = (multiSelectField ioptlist) #{optionDisplay opt} |] } + -- | Creates an input with @type="radio"@ for selecting one option. radioField :: (Eq a, RenderMessage site FormMessage) => HandlerFor site (OptionList a) @@ -552,6 +556,28 @@ $newline never |]) +-- | Creates an input with @type="radio"@ for selecting one option. +-- +-- @since 1.7.8 +radioField' :: (Eq a, RenderMessage site FormMessage) + => HandlerFor site (OptionList a) + -> Field (HandlerFor site) a +radioField' = withRadioField + (\theId optionWidget -> [whamlet| +$newline never +<.radio> + ^{optionWidget} +