yesod-form-1.2.1.3: Form handling support for Yesod Web Framework

Safe Haskell | None

Yesod.Form.Fields

Contents

- i18n
- Fields
- File `AForm`s
- Options

Synopsis

- data FormMessage
  - = MsgInvalidInteger Text
  - | MsgInvalidNumber Text
  - | MsgInvalidEntry Text
  - | MsgInvalidUrl Text
  - | MsgInvalidEmail Text
  - | MsgInvalidTimeFormat
  - | MsgInvalidHour Text
  - | MsgInvalidMinute Text
  - | MsgInvalidSecond Text
  - | MsgInvalidDay
  - | MsgCsrfWarning
  - | MsgValueRequired
  - | MsgInputNotFound Text
  - | MsgSelectNone
  - | MsgInvalidBool Text
  - | MsgBoolYes
  - | MsgBoolNo
  - | MsgDelete
- defaultFormMessage :: FormMessage -> Text
- textField :: RenderMessage master FormMessage => Field sub master Text
- passwordField :: RenderMessage master FormMessage => Field sub master Text
- textareaField :: RenderMessage master FormMessage => Field sub master Textarea
- hiddenField :: (PathPiece p, RenderMessage master FormMessage) => Field sub master p
- intField :: (Integral i, RenderMessage master FormMessage) => Field sub master i
- dayField :: RenderMessage master FormMessage => Field sub master Day
- timeField :: RenderMessage master FormMessage => Field sub master TimeOfDay
- htmlField :: RenderMessage master FormMessage => Field sub master Html
- emailField :: RenderMessage master FormMessage => Field sub master Text
- searchField :: RenderMessage master FormMessage => AutoFocus -> Field sub master Text
- type AutoFocus = Bool
- urlField :: RenderMessage master FormMessage => Field sub master Text
- doubleField :: RenderMessage master FormMessage => Field sub master Double
- parseDate :: String -> Either FormMessage Day
- parseTime :: Text -> Either FormMessage TimeOfDay
- newtype Textarea = Textarea {
  - unTextarea :: Text
  }
- boolField :: RenderMessage master FormMessage => Field sub master Bool
- checkBoxField :: RenderMessage m FormMessage => Field s m Bool
- fileField :: RenderMessage master FormMessage => Field sub master FileInfo
- fileAFormReq :: RenderMessage master FormMessage => FieldSettings master -> AForm sub master FileInfo
- fileAFormOpt :: RenderMessage master FormMessage => FieldSettings master -> AForm sub master (Maybe FileInfo)
- selectField :: (Eq a, RenderMessage master FormMessage) => GHandler sub master (OptionList a) -> Field sub master a
- selectFieldList :: (Eq a, RenderMessage master FormMessage, RenderMessage master msg) => [(msg, a)] -> Field sub master a
- radioField :: (Eq a, RenderMessage master FormMessage) => GHandler sub master (OptionList a) -> Field sub master a
- radioFieldList :: (Eq a, RenderMessage master FormMessage, RenderMessage master msg) => [(msg, a)] -> Field sub master a
- multiSelectField :: (Eq a, RenderMessage master FormMessage) => GHandler sub master (OptionList a) -> Field sub master [a]
- multiSelectFieldList :: (Eq a, RenderMessage master FormMessage, RenderMessage master msg) => [(msg, a)] -> Field sub master [a]
- data Option a = Option {
  - optionDisplay :: Text
  - optionInternalValue :: a
  - optionExternalValue :: Text
  }
- data OptionList a = OptionList {
  - olOptions :: [Option a]
  - olReadExternal :: Text -> Maybe a
  }
- mkOptionList :: [Option a] -> OptionList a
- optionsPersist :: (YesodPersist master, PersistEntity a, PersistQuery (YesodPersistBackend master (GHandler sub master)), PathPiece (Key a), PersistEntityBackend a ~ PersistMonadBackend (YesodPersistBackend master (GHandler sub master)), RenderMessage master msg) => [Filter a] -> [SelectOpt a] -> (a -> msg) -> GHandler sub master (OptionList (Entity a))
- optionsPairs :: RenderMessage master msg => [(msg, a)] -> GHandler sub master (OptionList a)
- optionsEnum :: (Show a, Enum a, Bounded a) => GHandler sub master (OptionList a)

# i18n

data FormMessage

Constructors

MsgInvalidInteger Text |
MsgInvalidNumber Text |
MsgInvalidEntry Text |
MsgInvalidUrl Text |
MsgInvalidEmail Text |
MsgInvalidTimeFormat |
MsgInvalidHour Text |
MsgInvalidMinute Text |
MsgInvalidSecond Text |
MsgInvalidDay |
MsgCsrfWarning |
MsgValueRequired |
MsgInputNotFound Text |
MsgSelectNone |
MsgInvalidBool Text |
MsgBoolYes |
MsgBoolNo |
MsgDelete |

Instances

Eq FormMessage |
Read FormMessage |
Show FormMessage |

defaultFormMessage :: FormMessage -> Text

# Fields

textField :: RenderMessage master FormMessage => Field sub master Text

passwordField :: RenderMessage master FormMessage => Field sub master Text

textareaField :: RenderMessage master FormMessage => Field sub master Textarea

hiddenField :: (PathPiece p, RenderMessage master FormMessage) => Field sub master p

intField :: (Integral i, RenderMessage master FormMessage) => Field sub master i

dayField :: RenderMessage master FormMessage => Field sub master Day

timeField :: RenderMessage master FormMessage => Field sub master TimeOfDay

htmlField :: RenderMessage master FormMessage => Field sub master Html

emailField :: RenderMessage master FormMessage => Field sub master Text

searchField :: RenderMessage master FormMessage => AutoFocus -> Field sub master Text

type AutoFocus = Bool

urlField :: RenderMessage master FormMessage => Field sub master Text

doubleField :: RenderMessage master FormMessage => Field sub master Double

parseDate :: String -> Either FormMessage Day

parseTime :: Text -> Either FormMessage TimeOfDay

newtype Textarea

A newtype wrapper around a `Text` that converts newlines to HTML br-tags.

Constructors

Textarea |
Fields unTextarea :: Text

Instances

Eq Textarea |
Ord Textarea |
Read Textarea |
Show Textarea |
ToMarkup Textarea |
PersistField Textarea |
ToField Textarea master |
ToField (Maybe Textarea) master |

boolField :: RenderMessage master FormMessage => Field sub master Bool

checkBoxField :: RenderMessage m FormMessage => Field s m Bool

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.

fileField :: RenderMessage master FormMessage => Field sub master FileInfo

# File `AForm`s

fileAFormReq :: RenderMessage master FormMessage => FieldSettings master -> AForm sub master FileInfo

fileAFormOpt :: RenderMessage master FormMessage => FieldSettings master -> AForm sub master (Maybe FileInfo)

# Options

selectField :: (Eq a, RenderMessage master FormMessage) => GHandler sub master (OptionList a) -> Field sub master a

selectFieldList :: (Eq a, RenderMessage master FormMessage, RenderMessage master msg) => [(msg, a)] -> Field sub master a

radioField :: (Eq a, RenderMessage master FormMessage) => GHandler sub master (OptionList a) -> Field sub master a

radioFieldList :: (Eq a, RenderMessage master FormMessage, RenderMessage master msg) => [(msg, a)] -> Field sub master a

multiSelectField :: (Eq a, RenderMessage master FormMessage) => GHandler sub master (OptionList a) -> Field sub master [a]

multiSelectFieldList :: (Eq a, RenderMessage master FormMessage, RenderMessage master msg) => [(msg, a)] -> Field sub master [a]

data Option a

Constructors

Option |
Fields optionDisplay :: Text optionInternalValue :: a optionExternalValue :: Text

data OptionList a

Constructors

OptionList |
Fields olOptions :: [Option a] olReadExternal :: Text -> Maybe a

mkOptionList :: [Option a] -> OptionList a

optionsPersist :: (YesodPersist master, PersistEntity a, PersistQuery (YesodPersistBackend master (GHandler sub master)), PathPiece (Key a), PersistEntityBackend a ~ PersistMonadBackend (YesodPersistBackend master (GHandler sub master)), RenderMessage master msg) => [Filter a] -> [SelectOpt a] -> (a -> msg) -> GHandler sub master (OptionList (Entity a))

optionsPairs :: RenderMessage master msg => [(msg, a)] -> GHandler sub master (OptionList a)

optionsEnum :: (Show a, Enum a, Bounded a) => GHandler sub master (OptionList a)