ditto-0.3: ditto is a type-safe HTML form generation and validation library

Safe HaskellNone
LanguageHaskell98

Ditto.Generalized

Synopsis

Documentation

input :: (Monad m, FormError err input) => (input -> Either err a) -> (FormId -> a -> view) -> a -> Form m input err view a Source #

used for constructing elements like <input type="text">, which pure a single input value.

inputMaybe :: (Monad m, FormError err input) => (input -> Either err a) -> (FormId -> Maybe a -> view) -> Maybe a -> Form m input err view (Maybe a) Source #

used for elements like <input type="submit"> which are not always present in the form submission data.

inputMaybeReq :: (Monad m, FormError err input) => (input -> Either err a) -> (FormId -> Maybe a -> view) -> Maybe a -> Form m input err view a Source #

used to construct elements with optional initial values, which are still required

inputNoData :: Monad m => (FormId -> view) -> Form m input err view () Source #

used for elements like <input type="reset"> which take a value, but are never present in the form data set.

inputFile :: forall m input err view. (Monad m, FormInput input, FormError err input) => (FormId -> view) -> Form m input err view (FileType input) Source #

used for <input type="file">

inputMulti Source #

Arguments

:: (FormError err input, FormInput input, Monad m) 
=> [(a, lbl)]

value, label, initially checked

-> (FormId -> [(FormId, Int, lbl, Bool)] -> view)

function which generates the view

-> (a -> Bool)

isChecked/isSelected initially

-> Form m input err view [a] 

used for groups of checkboxes, <select multiple="multiple"> boxes

inputChoice Source #

Arguments

:: (FormError err input, FormInput input, Monad m) 
=> (a -> Bool)

is default

-> [(a, lbl)]

value, label

-> (FormId -> [(FormId, Int, lbl, Bool)] -> view)

function which generates the view

-> Form m input err view a 

radio buttons, single <select> boxes

inputChoiceForms Source #

Arguments

:: (Monad m, FormError err input, FormInput input) 
=> a 
-> [(Form m input err view a, lbl)]

value, label

-> (FormId -> [(FormId, Int, FormId, view, lbl, Bool)] -> view)

function which generates the view

-> Form m input err view a 

radio buttons, single <select> boxes

label :: Monad m => (FormId -> view) -> Form m input err view () Source #

used to create <label> elements

errors Source #

Arguments

:: Monad m 
=> ([err] -> view)

function to convert the err messages into a view

-> Form m input err view () 

used to add a list of err messages to a Form

This function automatically takes care of extracting only the errors that are relevent to the form element it is attached to via <++ or ++>.

childErrors :: Monad m => ([err] -> view) -> Form m input err view () Source #

similar to errors but includes err messages from children of the form as well.

withErrors :: Monad m => (view -> [err] -> view) -> Form m input err view a -> Form m input err view a Source #

modify the view of a form based on its errors