- newFormIdent :: MForm sub master Text
- askParams :: MForm sub master (Maybe Env)
- askFiles :: MForm sub master (Maybe FileEnv)
- formToAForm :: MForm sub master (FormResult a, FieldView sub master) -> AForm sub master a
- aFormToForm :: AForm sub master a -> MForm sub master (FormResult a, [FieldView sub master] -> [FieldView sub master])
- mreq :: (RenderMessage master msg, RenderMessage master FormMessage) => Field sub master a -> FieldSettings msg -> Maybe a -> MForm sub master (FormResult a, FieldView sub master)
- mopt :: RenderMessage master msg => Field sub master a -> FieldSettings msg -> Maybe (Maybe a) -> MForm sub master (FormResult (Maybe a), FieldView sub master)
- areq :: (RenderMessage master msg, RenderMessage master FormMessage) => Field sub master a -> FieldSettings msg -> Maybe a -> AForm sub master a
- aopt :: RenderMessage master msg => Field sub master a -> FieldSettings msg -> Maybe (Maybe a) -> AForm sub master (Maybe a)
- runFormPost :: RenderMessage master FormMessage => (Html -> MForm sub master (FormResult a, xml)) -> GHandler sub master ((FormResult a, xml), Enctype)
- runFormPostNoNonce :: (Html -> MForm sub master (FormResult a, xml)) -> GHandler sub master ((FormResult a, xml), Enctype)
- runFormGet :: (Html -> MForm sub master a) -> GHandler sub master (a, Enctype)
- generateFormPost :: RenderMessage master FormMessage => (Html -> MForm sub master (FormResult a, xml)) -> GHandler sub master ((FormResult a, xml), Enctype)
- generateFormGet :: (Html -> MForm sub master a) -> GHandler sub master (a, Enctype)
- type FormRender sub master a = AForm sub master a -> Html -> MForm sub master (FormResult a, GWidget sub master ())
- renderTable, renderDivs :: FormRender sub master a
- check :: RenderMessage master msg => (a -> Either msg a) -> Field sub master a -> Field sub master a
- checkBool :: RenderMessage master msg => (a -> Bool) -> msg -> Field sub master a -> Field sub master a
- checkM :: RenderMessage master msg => (a -> GGHandler sub master IO (Either msg a)) -> Field sub master a -> Field sub master a
- customErrorMessage :: SomeMessage master -> Field sub master a -> Field sub master a
Running in MForm monad
newFormIdent :: MForm sub master TextSource
Get a unique identifier.
Applicative/Monadic conversion
formToAForm :: MForm sub master (FormResult a, FieldView sub master) -> AForm sub master aSource
aFormToForm :: AForm sub master a -> MForm sub master (FormResult a, [FieldView sub master] -> [FieldView sub master])Source
Fields to Forms
mreq :: (RenderMessage master msg, RenderMessage master FormMessage) => Field sub master a -> FieldSettings msg -> Maybe a -> MForm sub master (FormResult a, FieldView sub master)Source
mopt :: RenderMessage master msg => Field sub master a -> FieldSettings msg -> Maybe (Maybe a) -> MForm sub master (FormResult (Maybe a), FieldView sub master)Source
areq :: (RenderMessage master msg, RenderMessage master FormMessage) => Field sub master a -> FieldSettings msg -> Maybe a -> AForm sub master aSource
aopt :: RenderMessage master msg => Field sub master a -> FieldSettings msg -> Maybe (Maybe a) -> AForm sub master (Maybe a)Source
Run a form
runFormPost :: RenderMessage master FormMessage => (Html -> MForm sub master (FormResult a, xml)) -> GHandler sub master ((FormResult a, xml), Enctype)Source
This function is used to both initially render a form and to later extract results from it. Note that, due to CSRF protection and a few other issues, forms submitted via GET and POST are slightly different. As such, be sure to call the relevant function based on how the form will be submitted, not the current request method.
For example, a common case is displaying a form on a GET request and having
the form submit to a POST page. In such a case, both the GET and POST
handlers should use runFormPost
.
runFormPostNoNonce :: (Html -> MForm sub master (FormResult a, xml)) -> GHandler sub master ((FormResult a, xml), Enctype)Source
Generate a blank form
generateFormPost :: RenderMessage master FormMessage => (Html -> MForm sub master (FormResult a, xml)) -> GHandler sub master ((FormResult a, xml), Enctype)Source
Similar to runFormPost
, except it always ignore the currently available
environment. This is necessary in cases like a wizard UI, where a single
page will both receive and incoming form and produce a new, blank form. For
general usage, you can stick with runFormPost
.
Rendering
type FormRender sub master a = AForm sub master a -> Html -> MForm sub master (FormResult a, GWidget sub master ())Source
renderTable, renderDivs :: FormRender sub master aSource
Validation
check :: RenderMessage master msg => (a -> Either msg a) -> Field sub master a -> Field sub master aSource
checkBool :: RenderMessage master msg => (a -> Bool) -> msg -> Field sub master a -> Field sub master aSource
Return the given error message if the predicate is false.
checkM :: RenderMessage master msg => (a -> GGHandler sub master IO (Either msg a)) -> Field sub master a -> Field sub master aSource
customErrorMessage :: SomeMessage master -> Field sub master a -> Field sub master aSource
Allows you to overwrite the error message on parse error.