named-formlet-0.2: A simple formlet library with named formlets.

Safe HaskellNone

Text.Formlet

Description

Mini formlets library.

Synopsis

Documentation

data Formlet a Source

A simple formlet data type, collects errors.

Constructors

Formlet 

Fields

formletValue :: Params -> Either [Text] a
 
formletName :: Maybe Text
 
formletHtml :: Params -> Html
 

Instances

formlet :: Text -> (Maybe Text -> Html) -> Formlet TextSource

Make a simple formlet.

req :: Formlet Text -> Formlet TextSource

Make an input required (non-empty text).

opt :: Formlet Text -> Formlet (Maybe Text)Source

Make an input optional (empty text is nothing).

wrap :: (Html -> Html) -> Formlet Text -> Formlet TextSource

Wrap/transform formlet's HTML.

integer :: Text -> Either Text IntegerSource

Integer parser.

textInput :: Text -> Text -> Maybe Text -> Formlet TextSource

Make a text input formlet with a label.

dropInput :: [(Text, Text)] -> Text -> Text -> Text -> Formlet TextSource

Make a drop down input with a label.

areaInput :: Text -> Text -> Maybe Text -> Formlet TextSource

Make a textarea input with a label.

submitInput :: Text -> Text -> HtmlSource

Make a submit (captioned) button.

parse :: (a -> Either Text b) -> Formlet a -> Formlet bSource

Parse a form value.

options :: (o -> Text) -> (o -> Text) -> [o] -> [(Text, Text)]Source

Make a list of options for use with the option formlet.

findOption :: (o -> Bool) -> [o] -> (o -> internalid) -> Either Text internalidSource

Lookup a real internal id from a slug.