Updated yesod-form docs

This commit is contained in:
Michael Snoyman 2011-07-28 14:37:41 +03:00
parent ab08057b5f
commit 704b5e742c
2 changed files with 14 additions and 4 deletions

View File

@ -147,6 +147,15 @@ aopt a b = formToAForm . mopt a b
runFormGeneric :: Monad m => Form master m a -> master -> [Text] -> Maybe (Env, FileEnv) -> m (a, Enctype)
runFormGeneric form master langs env = evalRWST form (env, master, langs) (IntSingle 1)
-- | 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'.
runFormPost :: RenderMessage master FormMessage
=> (Html -> Form master (GHandler sub master) (FormResult a, xml)) -> GHandler sub master ((FormResult a, xml), Enctype)
runFormPost form = do

View File

@ -115,9 +115,10 @@ data FieldView xml = FieldView
data Field xml msg a = Field
{ fieldParse :: [Text] -> Either msg (Maybe a)
, fieldView :: Text -- ^ ID
-> Text -- ^ name
-> Either Text a -- ^ value could be invalid text or a legitimate a
-> Bool -- ^ required?
-- | ID, name, (invalid text OR legimiate result), required?
, fieldView :: Text
-> Text
-> Either Text a
-> Bool
-> xml
}