HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleyesod-form-1.7.9Haskell2010

Yesod.Form

Parse forms (and query strings).

  • 4 types
  • 45 values

Creates 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.

newtypenewtype Textarea
#

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.

Constructors

Instances10Eq, Ord, Read, Show, IsString, FromJSON, …

Creates 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).

valuecheckBoxField :: Monad m => Field m Bool
#

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.

valueselectFieldHelper
  1. :: (Eq a, RenderMessage site FormMessage)
  2. => (Text -> Text -> [(Text, Text)] -> WidgetFor site () -> WidgetFor site ())

    Outermost part of the field

  3. -> (Text -> Text -> Bool -> WidgetFor site ())

    An option for None if the field is optional

  4. -> (Text -> Text -> [(Text, Text)] -> Text -> Bool -> Text -> WidgetFor site ())

    Other options

  5. -> Maybe (Text -> WidgetFor site ())

    Group headers placed inbetween options

  6. -> HandlerFor site (OptionList a)
  7. -> Field (HandlerFor site) a
#

A helper function for constucting selectFields with optional option groups. You may want to use this when you define your custom selectFields or radioFields.

datadata OptionList a
#

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.

Constructors

Instances1Functor
valueoptionsPersist
  1. :: (YesodPersist site, PersistQueryRead backend, PathPiece (Key a), RenderMessage site msg, YesodPersistBackend site ~ backend, PersistRecordBackend a backend)
  2. => [Filter a]
  3. -> [SelectOpt a]
  4. -> a -> msg
  5. -> HandlerFor site (OptionList (Entity a))
#

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 Eq
data 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] countryName