- data FormResult a
- = FormMissing
- | FormFailure [String]
- | FormSuccess a
- newtype GForm sub y xml a = GForm {}
- newFormIdent :: Monad m => StateT Ints m String
- deeperFormIdent :: Monad m => StateT Ints m ()
- shallowerFormIdent :: Monad m => StateT Ints m ()
- type Env = [(String, String)]
- type FileEnv = [(String, FileInfo)]
- data Enctype
- = UrlEncoded
- | Multipart
- data Ints
- requiredFieldHelper :: FieldProfile sub y a -> FormFieldSettings -> Maybe a -> FormField sub y a
- optionalFieldHelper :: FieldProfile sub y a -> FormFieldSettings -> FormletField sub y (Maybe a)
- fieldsToInput :: [FieldInfo sub y] -> [GWidget sub y ()]
- mapFormXml :: (xml1 -> xml2) -> GForm s y xml1 a -> GForm s y xml2 a
- checkForm :: (a -> FormResult b) -> GForm s m x a -> GForm s m x b
- checkField :: (a -> Either String b) -> FormField s m a -> FormField s m b
- askParams :: Monad m => StateT Ints (ReaderT Env m) Env
- askFiles :: Monad m => StateT Ints (ReaderT Env (ReaderT FileEnv m)) FileEnv
- liftForm :: Monad m => m a -> StateT Ints (ReaderT Env (ReaderT FileEnv m)) a
- data FieldInfo sub y = FieldInfo {}
- data FormFieldSettings = FormFieldSettings {}
- data FieldProfile sub y a = FieldProfile {}
- 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 ()]
Documentation
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) | |
Monoid m => Monoid (FormResult m) |
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.
The encoding type required by a form. The Show
instance produces values
that can be inserted directly into HTML.
requiredFieldHelper :: FieldProfile sub y a -> FormFieldSettings -> Maybe a -> FormField sub y aSource
Create a required field (ie, one that cannot be blank) from a
FieldProfile
.ngs
optionalFieldHelper :: FieldProfile sub y a -> FormFieldSettings -> FormletField sub y (Maybe a)Source
Create an optional field (ie, one that can be blank) from a
FieldProfile
.
fieldsToInput :: [FieldInfo sub y] -> [GWidget sub y ()]Source
mapFormXml :: (xml1 -> xml2) -> GForm s y xml1 a -> GForm s y xml2 aSource
Convert the XML in a GForm
.
checkForm :: (a -> FormResult b) -> GForm s m x a -> GForm s m x bSource
Add a validation check to a form.
Note that if there is a validation error, this message will not
automatically appear on the form; for that, you need to use checkField
.
Data types
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
.
data FormFieldSettings Source
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
.
Type synonyms
type FormletField sub y a = Maybe a -> FormField sub y aSource