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

Yesod.Form.Types

Contents

- Helpers
- Form
- Build forms

Synopsis

- data Enctype
  - = UrlEncoded
  - | Multipart
- data FormResult a
  - = FormMissing
  - | FormFailure [Text]
  - | FormSuccess a
- 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
- type Env = Map Text [Text]
- type FileEnv = Map Text FileInfo
- data Ints
  - = IntCons Int Ints
  - | IntSingle Int
- type Form sub master a = RWST (Maybe (Env, FileEnv), master, [Lang]) Enctype Ints (GGHandler sub master IO) a
- type MForm sub master a = RWST (Maybe (Env, FileEnv), master, [Lang]) Enctype Ints (GGHandler sub master IO) a
- newtype AForm sub master a = AForm {
  - unAForm :: (master, [Text]) -> Maybe (Env, FileEnv) -> Ints -> GGHandler sub master IO (FormResult a, [FieldView sub master] -> [FieldView sub master], Ints, Enctype)
  }
- data Field sub master a = Field {
  - fieldParse :: [Text] -> GGHandler sub master IO (Either (SomeMessage master) (Maybe a))
  - fieldView :: Text -> Text -> Either Text a -> Bool -> GWidget sub master ()
  }
- data FieldSettings msg = FieldSettings {
  - fsLabel :: msg
  - fsTooltip :: Maybe msg
  - fsId :: Maybe Text
  - fsName :: Maybe Text
  }
- data FieldView sub master = FieldView {
  - fvLabel :: Html
  - fvTooltip :: Maybe Html
  - fvId :: Text
  - fvInput :: GWidget sub master ()
  - fvErrors :: Maybe Html
  - fvRequired :: Bool
  }

# Helpers

data Enctype

The encoding type required by a form. The `ToHtml` instance produces values that can be inserted directly into HTML.

Constructors

UrlEncoded |
Multipart |

Instances

Bounded Enctype |
Enum Enctype |
Eq Enctype |
Monoid Enctype |
ToHtml Enctype |

data FormResult a

A form can produce three different results: there was no data available, the data was invalid, or there was a successful parse.

The `Applicative` instance will concatenate the failure messages in two `FormResult`s.

Constructors

FormMissing |
FormFailure [Text] |
FormSuccess a |

Instances

Functor FormResult |
Applicative FormResult |
Show a => Show (FormResult a) |
Monoid m => Monoid (FormResult m) |

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 |

type Env = Map Text [Text]

type FileEnv = Map Text FileInfo

data Ints

Constructors

IntCons Int Ints |
IntSingle Int |

Instances

Show Ints |

# Form

type Form sub master a = RWST (Maybe (Env, FileEnv), master, [Lang]) Enctype Ints (GGHandler sub master IO) a

type MForm sub master a = RWST (Maybe (Env, FileEnv), master, [Lang]) Enctype Ints (GGHandler sub master IO) a

newtype AForm sub master a

Constructors

AForm |

Fields

unAForm :: (master, [Text]) -> Maybe (Env, FileEnv) -> Ints -> GGHandler sub master IO (FormResult a, [FieldView sub master] -> [FieldView sub master], Ints, Enctype)

Instances

Functor (AForm sub master) |
Applicative (AForm sub master) |
Monoid a => Monoid (AForm sub master a) |

# Build forms

data Field sub master a

Constructors

Field |

Fields

fieldParse :: [Text] -> GGHandler sub master IO (Either (SomeMessage master) (Maybe a))
fieldView :: Text -> Text -> Either Text a -> Bool -> GWidget sub master ()

  ID, name, (invalid text OR legimiate result), required?

data FieldSettings msg

Constructors

FieldSettings |

Fields

fsLabel :: msg
fsTooltip :: Maybe msg
fsId :: Maybe Text
fsName :: Maybe Text

Instances

a ~ Text => IsString (FieldSettings a) |

data FieldView sub master

Constructors

FieldView |

Fields

fvLabel :: Html
fvTooltip :: Maybe Html
fvId :: Text
fvInput :: GWidget sub master ()
fvErrors :: Maybe Html
fvRequired :: Bool