Parse forms (and query strings).
- newtype GForm sub y xml a = GForm {}
- type Form sub y = GForm sub y (GWidget sub y ())
- type Formlet sub y a = Maybe a -> Form sub y a
- type FormField sub y = GForm sub y [FieldInfo sub y]
- type FormletField sub y a = Maybe a -> FormField sub y a
- type FormInput sub y = GForm sub y [GWidget sub y ()]
- data FormResult a
- = FormMissing
- | FormFailure [String]
- | FormSuccess a
- data Enctype
- = UrlEncoded
- | Multipart
- data FieldInfo sub y = FieldInfo {}
- newtype JqueryDay = JqueryDay {
- unJqueryDay :: Day
- newtype NicHtml = NicHtml {}
- type Html' = Html ()
- runFormGet :: GForm sub y xml a -> GHandler sub y (FormResult a, xml, Enctype)
- runFormPost :: GForm sub y xml a -> GHandler sub y (FormResult a, xml, Enctype)
- runFormGet' :: GForm sub y xml a -> GHandler sub y a
- runFormPost' :: GForm sub y xml a -> GHandler sub y a
- class ToForm a where
- class ToFormField a where
- requiredFieldHelper :: FieldProfile sub y a -> Maybe a -> FormField sub y a
- optionalFieldHelper :: FieldProfile sub y a -> Maybe (Maybe a) -> FormField sub y (Maybe a)
- mapFormXml :: (xml1 -> xml2) -> GForm s y xml1 a -> GForm s y xml2 a
- newFormIdent :: Monad m => StateT Int m String
- fieldsToTable :: [FieldInfo sub y] -> GWidget sub y ()
- fieldsToPlain :: [FieldInfo sub y] -> GWidget sub y ()
- fieldsToInput :: [FieldInfo sub y] -> [GWidget sub y ()]
- data FieldProfile sub y a = FieldProfile {}
- stringFieldProfile :: FieldProfile sub y String
- intFieldProfile :: Integral i => FieldProfile sub y i
- dayFieldProfile :: FieldProfile sub y Day
- jqueryDayFieldProfile :: FieldProfile sub y Day
- timeFieldProfile :: FieldProfile sub y TimeOfDay
- htmlFieldProfile :: FieldProfile sub y (Html ())
- emailFieldProfile :: FieldProfile s y String
- stringField :: Html () -> Html () -> FormletField sub y String
- maybeStringField :: Html () -> Html () -> FormletField sub y (Maybe String)
- intField :: Integral i => Html () -> Html () -> FormletField sub y i
- maybeIntField :: Integral i => Html () -> Html () -> FormletField sub y (Maybe i)
- doubleField :: Html () -> Html () -> FormletField sub y Double
- maybeDoubleField :: Html () -> Html () -> FormletField sub y (Maybe Double)
- dayField :: Html () -> Html () -> FormletField sub y Day
- maybeDayField :: Html () -> Html () -> FormletField sub y (Maybe Day)
- jqueryDayField :: Html () -> Html () -> FormletField sub y Day
- maybeJqueryDayField :: Html () -> Html () -> FormletField sub y (Maybe Day)
- timeField :: Html () -> Html () -> FormletField sub y TimeOfDay
- maybeTimeField :: Html () -> Html () -> FormletField sub y (Maybe TimeOfDay)
- htmlField :: Html () -> Html () -> FormletField sub y (Html ())
- maybeHtmlField :: Html () -> Html () -> FormletField sub y (Maybe (Html ()))
- nicHtmlField :: Html () -> Html () -> FormletField sub y (Html ())
- maybeNicHtmlField :: Html () -> Html () -> FormletField sub y (Maybe (Html ()))
- selectField :: Eq x => [(x, String)] -> Html () -> Html () -> Maybe x -> FormField sub master x
- maybeSelectField :: Eq x => [(x, String)] -> Html () -> Html () -> Maybe x -> FormField sub master (Maybe x)
- boolField :: Html () -> Html () -> Maybe Bool -> FormField sub y Bool
- jqueryAutocompleteField :: Route y -> Html () -> Html () -> FormletField sub y String
- maybeJqueryAutocompleteField :: Route y -> Html () -> Html () -> FormletField sub y (Maybe String)
- emailField :: Html () -> Html () -> FormletField sub y String
- maybeEmailField :: Html () -> Html () -> FormletField sub y (Maybe String)
- stringInput :: String -> FormInput sub master String
- maybeStringInput :: String -> FormInput sub master (Maybe String)
- boolInput :: String -> FormInput sub master Bool
- dayInput :: String -> FormInput sub master Day
- maybeDayInput :: String -> FormInput sub master (Maybe Day)
- emailInput :: String -> FormInput sub master String
- share2 :: Monad m => (a -> m [b]) -> (a -> m [b]) -> a -> m [b]
- mkToForm :: [EntityDef] -> Q [Dec]
Data types
newtype GForm sub y xml a Source
A generic form, allowing you to specifying the subsite datatype, master site datatype, a datatype for the form XML and the return type.
type FormletField sub y a = Maybe a -> FormField sub y aSource
data FormResult a Source
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.
Functor FormResult | |
Applicative FormResult | |
Show a => Show (FormResult a) |
The encoding type required by a form. The Show
instance produces values
that can be inserted directly into HTML.
Using this as the intermediate XML representation for fields allows us to
write generic field functions and then different functions for producing
actual HTML. See, for example, fieldsToTable
and fieldsToPlain
.
Newtype wrappers
A newtype wrapper around Day
, using jQuery UI date picker for the
ToFormField
instance.
Unwrapping functions
runFormGet :: GForm sub y xml a -> GHandler sub y (FormResult a, xml, Enctype)Source
Run a form against GET parameters.
runFormPost :: GForm sub y xml a -> GHandler sub y (FormResult a, xml, Enctype)Source
Run a form against POST parameters.
runFormGet' :: GForm sub y xml a -> GHandler sub y aSource
Run a form against GET parameters, disregarding the resulting HTML and returning an error response on invalid input.
runFormPost' :: GForm sub y xml a -> GHandler sub y aSource
Run a form against POST parameters, disregarding the resulting HTML and returning an error response on invalid input.
Type classes
class ToFormField a whereSource
Field/form helpers
requiredFieldHelper :: FieldProfile sub y a -> Maybe a -> FormField sub y aSource
Create a required field (ie, one that cannot be blank) from a
FieldProfile
.
optionalFieldHelper :: FieldProfile sub y a -> Maybe (Maybe a) -> FormField sub y (Maybe a)Source
Create an optional field (ie, one that can be blank) from a
FieldProfile
.
mapFormXml :: (xml1 -> xml2) -> GForm s y xml1 a -> GForm s y xml2 aSource
Convert the XML in a GForm
.
fieldsToTable :: [FieldInfo sub y] -> GWidget sub y ()Source
Display the label, tooltip, input code and errors in a single row of a table.
fieldsToPlain :: [FieldInfo sub y] -> GWidget sub y ()Source
Display only the actual input widget code, without any decoration.
fieldsToInput :: [FieldInfo sub y] -> [GWidget sub y ()]Source
Field profiles
data FieldProfile sub y a Source
A generic definition of a form field that can be used for generating both
required and optional fields. See 'requiredFieldHelper and
optionalFieldHelper
.
stringFieldProfile :: FieldProfile sub y StringSource
intFieldProfile :: Integral i => FieldProfile sub y iSource
dayFieldProfile :: FieldProfile sub y DaySource
jqueryDayFieldProfile :: FieldProfile sub y DaySource
timeFieldProfile :: FieldProfile sub y TimeOfDaySource
htmlFieldProfile :: FieldProfile sub y (Html ())Source
Pre-built fields
stringField :: Html () -> Html () -> FormletField sub y StringSource
maybeStringField :: Html () -> Html () -> FormletField sub y (Maybe String)Source
maybeIntField :: Integral i => Html () -> Html () -> FormletField sub y (Maybe i)Source
doubleField :: Html () -> Html () -> FormletField sub y DoubleSource
maybeDoubleField :: Html () -> Html () -> FormletField sub y (Maybe Double)Source
maybeDayField :: Html () -> Html () -> FormletField sub y (Maybe Day)Source
jqueryDayField :: Html () -> Html () -> FormletField sub y DaySource
maybeJqueryDayField :: Html () -> Html () -> FormletField sub y (Maybe Day)Source
maybeTimeField :: Html () -> Html () -> FormletField sub y (Maybe TimeOfDay)Source
maybeHtmlField :: Html () -> Html () -> FormletField sub y (Maybe (Html ()))Source
nicHtmlField :: Html () -> Html () -> FormletField sub y (Html ())Source
maybeNicHtmlField :: Html () -> Html () -> FormletField sub y (Maybe (Html ()))Source
selectField :: Eq x => [(x, String)] -> Html () -> Html () -> Maybe x -> FormField sub master xSource
maybeSelectField :: Eq x => [(x, String)] -> Html () -> Html () -> Maybe x -> FormField sub master (Maybe x)Source
jqueryAutocompleteField :: Route y -> Html () -> Html () -> FormletField sub y StringSource
maybeJqueryAutocompleteField :: Route y -> Html () -> Html () -> FormletField sub y (Maybe String)Source
emailField :: Html () -> Html () -> FormletField sub y StringSource
maybeEmailField :: Html () -> Html () -> FormletField sub y (Maybe String)Source
Pre-built inputs
stringInput :: String -> FormInput sub master StringSource
emailInput :: String -> FormInput sub master StringSource