reform-0.2.0: reform is an HTML form generation and validation library

Safe Haskell | None

Text.Reform.Generalized

Description

This module provides helper functions for HTML input elements. These helper functions are not specific to any particular web framework or html library.

Synopsis

- input :: (Monad m, FormError error) => (input -> Either error a) -> (FormId -> a -> view) -> a -> Form m input error view () a
- inputMaybe :: (Monad m, FormError error) => (input -> Either error a) -> (FormId -> a -> view) -> a -> Form m input error view () (Maybe a)
- inputNoData :: Monad m => (FormId -> a -> view) -> a -> Form m input error view () ()
- inputFile :: forall m input error view. (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) => (FormId -> view) -> Form m input error view () (FileType input)
- inputMulti :: forall m input error view a lbl. (Functor m, FormError error, ErrorInputType error ~ input, FormInput input, Monad m) => [(a, lbl)] -> (FormId -> [(FormId, Int, lbl, Bool)] -> view) -> (a -> Bool) -> Form m input error view () [a]
- inputChoice :: forall a m error input lbl view. (Functor m, FormError error, ErrorInputType error ~ input, FormInput input, Monad m) => (a -> Bool) -> [(a, lbl)] -> (FormId -> [(FormId, Int, lbl, Bool)] -> view) -> Form m input error view () a
- label :: Monad m => (FormId -> view) -> Form m input error view () ()
- errors :: Monad m => ([error] -> view) -> Form m input error view () ()
- childErrors :: Monad m => ([error] -> view) -> Form m input error view () ()

# Documentation

input :: (Monad m, FormError error) => (input -> Either error a) -> (FormId -> a -> view) -> a -> Form m input error view () aSource

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

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

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

inputNoData :: Monad m => (FormId -> a -> view) -> a -> Form m input error 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 error view. (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) => (FormId -> view) -> Form m input error view () (FileType input)Source

used for `<input type="file">`

inputMulti Source

Arguments

:: forall m input error view a lbl . (Functor m, FormError error, ErrorInputType error ~ 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 error view () [a] |

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

inputChoice Source

Arguments

:: forall a m error input lbl view . (Functor m, FormError error, ErrorInputType error ~ 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 error view () a |

radio buttons, single `<select>` boxes

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

used to create `<label>` elements

errors Source

Arguments

:: Monad m |
=> ([error] -> view) | function to convert the error messages into a view
-> Form m input error view () () |

used to add a list of error 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 => ([error] -> view) -> Form m input error view () ()Source

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