From 0b261f50733a5c461eff470d1580f742beded9d6 Mon Sep 17 00:00:00 2001 From: pythonissam Date: Sun, 17 Jun 2018 08:40:55 +0000 Subject: [PATCH] Exposed 'selectFieldHelper' --- yesod-form/Yesod/Form/Fields.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/yesod-form/Yesod/Form/Fields.hs b/yesod-form/Yesod/Form/Fields.hs index d64776ff..37c53942 100644 --- a/yesod-form/Yesod/Form/Fields.hs +++ b/yesod-form/Yesod/Form/Fields.hs @@ -42,6 +42,7 @@ module Yesod.Form.Fields , fileAFormOpt -- * Options -- $optionsOverview + , selectFieldHelper , selectField , selectFieldList , radioField @@ -729,11 +730,15 @@ optionsPersistKey filts ords toDisplay = fmap mkOptionList $ do , optionExternalValue = toPathPiece key }) pairs +-- | +-- A helper function for constucting 'selectField's. You may want to use this when you define your custom 'selectField's or 'radioField's. +-- +-- Since 1.6.4 selectFieldHelper :: (Eq a, RenderMessage site FormMessage) - => (Text -> Text -> [(Text, Text)] -> WidgetFor site () -> WidgetFor site ()) - -> (Text -> Text -> Bool -> WidgetFor site ()) - -> (Text -> Text -> [(Text, Text)] -> Text -> Bool -> Text -> WidgetFor site ()) + => (Text -> Text -> [(Text, Text)] -> WidgetFor site () -> WidgetFor site ()) -- ^ Outermost part of the field + -> (Text -> Text -> Bool -> WidgetFor site ()) -- ^ An option for None if the field is optional + -> (Text -> Text -> [(Text, Text)] -> Text -> Bool -> Text -> WidgetFor site ()) -- ^ Other options -> HandlerFor site (OptionList a) -> Field (HandlerFor site) a selectFieldHelper outside onOpt inside opts' = Field