reform-0.2.7.4: reform is a type-safe HTML form generation and validation library

Safe HaskellNone
LanguageHaskell98

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

Documentation

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

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

:: (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

:: (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

inputChoiceForms Source #

Arguments

:: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input) 
=> a 
-> [(Form m input error view proof a, lbl)]

value, label

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

function which generates the view

-> Form m input error view proof 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.