Constructors
OptionoptionDisplay :: TextThe user-facing label.
optionInternalValue :: aThe Haskell value being selected.
optionExternalValue :: TextThe representation of this value stored in the form.
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05
Moduleyesod-form-1.7.9Haskell2010
Parse forms (and query strings).
module Yesod.Form.Types
module Yesod.Form.Functions
OptionoptionDisplay :: TextThe user-facing label.
optionInternalValue :: aThe Haskell value being selected.
optionExternalValue :: TextThe representation of this value stored in the form.
Creates a input with type="text".
Creates an input with type="password".
Creates a input with type="number" and step=1.
Creates an input with type="date", validating the input using the parseDate function.
Add the time package and import the Data.Time.Calendar module to use this function.
An alias for timeFieldTypeTime.
timeFieldTypeTime :: (Monad m, RenderMessage (HandlerSite m) FormMessage) => Field m TimeOfDayCreates an input with type="time". Browsers not supporting this type will fallback to a text field, and Yesod will parse the time as described in timeFieldTypeText.
Add the time package and import the Data.Time.LocalTime module to use this function.
timeFieldTypeText :: (Monad m, RenderMessage (HandlerSite m) FormMessage) => Field m TimeOfDayCreates an input with type="text", parsing the time from an [H]H:MM[:SS] format, with an optional AM or PM (if not given, AM is assumed for compatibility with the 24 hour clock system).
This function exists for backwards compatibility with the old implementation of timeField, which used to use type="text". Consider using timeField or timeFieldTypeTime for improved UX and validation from the browser.
Add the time package and import the Data.Time.LocalTime module to use this function.
Creates a <textarea> tag whose input is sanitized to prevent XSS attacks and is validated for having balanced tags.
Creates an input with type="email". Yesod will validate the email's correctness according to RFC5322 and canonicalize it by removing comments and whitespace (see Text.Email.Validate).
Creates an input with type="email" with the multiple attribute; browsers might implement this as taking a comma separated list of emails. Each email address is validated as described in emailField.
Creates an input with type="search". For browsers without autofocus support, a JS fallback is used if AutoFocus is true.
Creates an input with type="url", validating the URL according to RFC3986.
Creates a input with type="number" and step=any.
A newtype wrapper around a Text whose ToMarkup instance converts newlines to HTML <br> tags.
(When text is entered into a <textarea>, newline characters are used to separate lines.
If this text is then placed verbatim into HTML, the lines won't be separated, thus the need for replacing with <br> tags).
If you don't need this functionality, simply use unTextarea to access the raw text.
Eq TextareaDefined in yesod-form-1.7.9 · Yesod.Form.FieldsOrd TextareaDefined in yesod-form-1.7.9 · Yesod.Form.FieldsRead TextareaDefined in yesod-form-1.7.9 · Yesod.Form.FieldsShow TextareaDefined in yesod-form-1.7.9 · Yesod.Form.FieldsIsString TextareaDefined in yesod-form-1.7.9 · Yesod.Form.FieldsFromJSON TextareaDefined in yesod-form-1.7.9 · Yesod.Form.FieldsToJSON TextareaDefined in yesod-form-1.7.9 · Yesod.Form.FieldsToMarkup TextareaDefined in yesod-form-1.7.9 · Yesod.Form.FieldsPersistField TextareaDefined in yesod-form-1.7.9 · Yesod.Form.FieldsPersistFieldSql TextareaDefined in yesod-form-1.7.9 · Yesod.Form.FieldsCreates a group of radio buttons to answer the question given in the message. Radio buttons are used to allow differentiating between an empty response (Nothing) and a no response (Just False). Consider using the simpler checkBoxField if you don't need to make this distinction.
If this field is optional, the first radio button is labeled "<None>", the second "Yes" and the third "No".
If this field is required, the first radio button is labeled "Yes" and the second "No".
(Exact label titles will depend on localization).
Creates an input with type="checkbox".
While the default boolField implements a radio button so you
can differentiate between an empty response (Nothing) and a no
response (Just False), this simpler checkbox field returns an empty
response as Just False.
Note that this makes the field always optional.
Creates an input with type="file".
selectFieldHelper :: (Eq a, RenderMessage site FormMessage)=> (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
-> Maybe (Text -> WidgetFor site ())Group headers placed inbetween options
-> HandlerFor site (OptionList a)-> Field (HandlerFor site) aA helper function for constucting selectFields with optional option groups. You may want to use this when you define your custom selectFields or radioFields.
Creates a <select> tag with optional <optgroup>s for selecting one option. Example usage:
areq (selectField $ optionsPairs [(MsgValue1, "value1"),(MsgValue2, "value2")]) "Which value?" NothingCreates a <select> tag for selecting one option. Example usage:
areq (selectFieldList [("Value 1" :: Text, "value1"),("Value 2", "value2")]) "Which value?" NothingCreates a <select> tag with <optgroup>s for selecting one option.
Deprecated. This function seems to have a bug (label could not be found with byLabel algorithm)
Creates an input with type="radio" for selecting one option.
Creates an input with type="radio" for selecting one option.
Creates an input with type="radio" for selecting one option.
withRadioField :: (Eq a, RenderMessage site FormMessage)=> (Text -> WidgetFor site () -> WidgetFor site ())nothing case for mopt
-> (Text -> Text -> Bool -> Text -> WidgetFor site () -> WidgetFor site ())cases for values
-> HandlerFor site (OptionList a)-> Field (HandlerFor site) aAllows the user to place the option radio widget somewhere in the template. For example: If you want a table of radio options to select. radioField is an example on how to use this function.
Deprecated. This function seems to have a bug (label could not be found with byLabel algorithm)
Creates an input with type="checkbox" for selecting multiple options.
Creates an input with type="checkbox" for selecting multiple options.
Creates an input with type="checkbox" for selecting multiple options.
Creates a <select> tag for selecting multiple options.
Creates a <select> tag for selecting multiple options.
A structure holding a list of options. Typically you can use a convenience function like mkOptionList or optionsPairs instead of creating this directly.
Extended by OptionListGrouped in 1.7.0.
OptionListolOptions :: [Option a]olReadExternal :: Text -> Maybe aA function mapping from the form's value (optionExternalValue) to the selected Haskell value (optionInternalValue).
OptionListGroupedolOptionsGrouped :: [(Text, [Option a])]olReadExternalGrouped :: Text -> Maybe aA function mapping from the form's value (optionExternalValue) to the selected Haskell value (optionInternalValue).
Functor OptionListDefined in yesod-form-1.7.9 · Yesod.Form.FieldsCreates an OptionList, using a Map to implement the olReadExternal function.
Creates an OptionList, using a Map to implement the olReadExternalGrouped function.
Selects a list of Entitys with the given Filter and SelectOpts. The (a -> msg) function is then used to derive the display value for an OptionList. Example usage:
Country
name Text
deriving Eq -- Must derive Eqdata CountryForm = CountryForm
{ country :: Entity Country
}
countryNameForm :: AForm Handler CountryForm
countryNameForm = CountryForm
<$> areq (selectField countries) "Which country do you live in?" Nothing
where
countries = optionsPersist [] [Asc CountryName] countryNameAn alternative to optionsPersist which returns just the Key instead of the entire Entity.
Creates an OptionList from a list of (display-value, internal value) pairs.
Creates an OptionList from a list of (display-value, internal value) pairs.
Creates an OptionList from an Enum, using its Show instance for the user-facing value.
Creates an input with type="color".
The input value must be provided in hexadecimal format #rrggbb.
datetimeLocalField :: (Monad m, RenderMessage (HandlerSite m) FormMessage) => Field m LocalTimeCreates an input with type="datetime-local".
The input value must be provided in YYYY-MM-DD(T| )HH:MM[:SS] format.
module Yesod.Form.Input