ContentsIndex
Framework.Forms.Types
Description
HTML forms generation and validation.
Synopsis
data Form = Form {
formName :: String
formModel :: Model
fFields :: [FormField]
}
data FormField = forall w . Widget w => Field {
fName :: String
fLabel :: String
fWidget :: w
fValidate :: FieldValidator
}
data HTMLForm = HTMLForm {
visibleFields :: HTML
hiddenFields :: HTML
htmlFormName :: String
formId :: String
formAction :: String
}
data HTMLTag
= Tag {
tagName :: String
tagAttrs :: [FormVar]
tagContent :: HTML
mayCollapse :: Bool
}
| Text String
| Translatable String
type HTML = [HTMLTag]
class Widget w where
type WContent w
html :: w -> String -> String -> HTMLTag
wRead :: String -> WContent w
type FormProcessors = [Form -> FormController]
type FormController = AController Form
type HTMLProcessors = [HTML -> HTMLController]
type HTMLController = AController HTML
type FormValidator = HttpRequest -> Either [(String, String)] Model
type FieldValidator = HttpRequest -> String -> String -> Either String String
Documentation
data Form
Constructors
Form
formName :: String
formModel :: Model
fFields :: [FormField]
show/hide Instances
Show Form
data FormField
Constructors
forall w . Widget w => Field
fName :: String
fLabel :: String
fWidget :: w
fValidate :: FieldValidator
show/hide Instances
data HTMLForm
Constructors
HTMLForm
visibleFields :: HTML
hiddenFields :: HTML
htmlFormName :: String
formId :: String
formAction :: String
data HTMLTag
Constructors
Tag
tagName :: String
tagAttrs :: [FormVar]
tagContent :: HTML
mayCollapse :: BoolMay we collapse tag></tag> to <tag/ ?
Text String
Translatable String
type HTML = [HTMLTag]
class Widget w where
Types of this class represent HTML widgets
Associated Types
type WContent w
Type of widget content; not used at the moment.
Methods
html
:: wA widget
-> StringWidget's html "name" attribute
-> StringValue of widget
-> HTMLTag
Generate HTML for widget
wRead :: String -> WContent w
Read widget's value from string. Not used yet.
show/hide Instances
type FormProcessors = [Form -> FormController]
Form plugin transforms a Form
type FormController = AController Form
type HTMLProcessors = [HTML -> HTMLController]
type HTMLController = AController HTML
type FormValidator = HttpRequest -> Either [(String, String)] Model
Form validator takes request and returns either list of erroneus filled field or filled Model
type FieldValidator = HttpRequest -> String -> String -> Either String String
Field validator takes field value and returns either error message or validated value
Produced by Haddock version 2.4.2