yesod-form-1.3.0: 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 :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Text
- passwordField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Text
- textareaField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Textarea
- hiddenField :: (Monad m, PathPiece p, RenderMessage (HandlerSite m) FormMessage) => Field m p
- intField :: (Monad m, Integral i, RenderMessage (HandlerSite m) FormMessage) => Field m i
- dayField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Day
- timeField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m TimeOfDay
- htmlField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Html
- emailField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Text
- searchField :: Monad m => RenderMessage (HandlerSite m) FormMessage => AutoFocus -> Field m Text
- type AutoFocus = Bool
- urlField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Text
- doubleField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Double
- parseDate :: String -> Either FormMessage Day
- parseTime :: Text -> Either FormMessage TimeOfDay
- newtype Textarea = Textarea {
  - unTextarea :: Text
  }
- boolField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Bool
- checkBoxField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Bool
- fileField :: (Monad m, RenderMessage (HandlerSite m) FormMessage) => Field m FileInfo
- fileAFormReq :: (MonadHandler m, RenderMessage (HandlerSite m) FormMessage) => FieldSettings (HandlerSite m) -> AForm m FileInfo
- fileAFormOpt :: MonadHandler m => RenderMessage (HandlerSite m) FormMessage => FieldSettings (HandlerSite m) -> AForm m (Maybe FileInfo)
- selectField :: (Eq a, RenderMessage site FormMessage) => HandlerT site IO (OptionList a) -> Field (HandlerT site IO) a
- selectFieldList :: (Eq a, RenderMessage site FormMessage, RenderMessage site msg) => [(msg, a)] -> Field (HandlerT site IO) a
- radioField :: (Eq a, RenderMessage site FormMessage) => HandlerT site IO (OptionList a) -> Field (HandlerT site IO) a
- radioFieldList :: (Eq a, RenderMessage site FormMessage, RenderMessage site msg) => [(msg, a)] -> Field (HandlerT site IO) a
- multiSelectField :: (Eq a, RenderMessage site FormMessage) => HandlerT site IO (OptionList a) -> Field (HandlerT site IO) [a]
- multiSelectFieldList :: (Eq a, RenderMessage site FormMessage, RenderMessage site msg) => [(msg, a)] -> Field (HandlerT site IO) [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 site, PersistEntity a, PersistQuery (YesodDB site), PathPiece (Key a), PersistEntityBackend a ~ PersistMonadBackend (YesodDB site), RenderMessage site msg) => [Filter a] -> [SelectOpt a] -> (a -> msg) -> HandlerT site IO (OptionList (Entity a))
- optionsPairs :: (MonadHandler m, RenderMessage (HandlerSite m) msg) => [(msg, a)] -> m (OptionList a)
- optionsEnum :: (MonadHandler m, Show a, Enum a, Bounded a) => m (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 :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Text

passwordField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Text

textareaField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Textarea

hiddenField :: (Monad m, PathPiece p, RenderMessage (HandlerSite m) FormMessage) => Field m p

intField :: (Monad m, Integral i, RenderMessage (HandlerSite m) FormMessage) => Field m i

dayField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Day

timeField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m TimeOfDay

htmlField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Html

emailField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Text

searchField :: Monad m => RenderMessage (HandlerSite m) FormMessage => AutoFocus -> Field m Text

type AutoFocus = Bool

urlField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Text

doubleField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m 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 |
PersistFieldSql Textarea |
PersistField Textarea |

boolField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Bool

checkBoxField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field 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 :: (Monad m, RenderMessage (HandlerSite m) FormMessage) => Field m FileInfo

# File `AForm`s

fileAFormReq :: (MonadHandler m, RenderMessage (HandlerSite m) FormMessage) => FieldSettings (HandlerSite m) -> AForm m FileInfo

fileAFormOpt :: MonadHandler m => RenderMessage (HandlerSite m) FormMessage => FieldSettings (HandlerSite m) -> AForm m (Maybe FileInfo)

# Options

selectField :: (Eq a, RenderMessage site FormMessage) => HandlerT site IO (OptionList a) -> Field (HandlerT site IO) a

selectFieldList :: (Eq a, RenderMessage site FormMessage, RenderMessage site msg) => [(msg, a)] -> Field (HandlerT site IO) a

radioField :: (Eq a, RenderMessage site FormMessage) => HandlerT site IO (OptionList a) -> Field (HandlerT site IO) a

radioFieldList :: (Eq a, RenderMessage site FormMessage, RenderMessage site msg) => [(msg, a)] -> Field (HandlerT site IO) a

multiSelectField :: (Eq a, RenderMessage site FormMessage) => HandlerT site IO (OptionList a) -> Field (HandlerT site IO) [a]

multiSelectFieldList :: (Eq a, RenderMessage site FormMessage, RenderMessage site msg) => [(msg, a)] -> Field (HandlerT site IO) [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 site, PersistEntity a, PersistQuery (YesodDB site), PathPiece (Key a), PersistEntityBackend a ~ PersistMonadBackend (YesodDB site), RenderMessage site msg) => [Filter a] -> [SelectOpt a] -> (a -> msg) -> HandlerT site IO (OptionList (Entity a))

optionsPairs :: (MonadHandler m, RenderMessage (HandlerSite m) msg) => [(msg, a)] -> m (OptionList a)

optionsEnum :: (MonadHandler m, Show a, Enum a, Bounded a) => m (OptionList a)