yesod-form-1.4.12: Form handling support for Yesod Web Framework

Safe Haskell | None
Language | Haskell98

Yesod.Form.Input

Description

Provides for getting input from either GET or POST params without generating HTML forms. For more information, see: http://www.yesodweb.com/book/forms#forms_kinds_of_forms.

Synopsis

- newtype FormInput m a = FormInput {
  - unFormInput :: HandlerSite m -> [Text] -> Env -> FileEnv -> m (Either DText a)
  }
- runInputGet :: MonadHandler m => FormInput m a -> m a
- runInputGetResult :: MonadHandler m => FormInput m a -> m (FormResult a)
- runInputPost :: MonadHandler m => FormInput m a -> m a
- runInputPostResult :: MonadHandler m => FormInput m a -> m (FormResult a)
- ireq :: (Monad m, RenderMessage (HandlerSite m) FormMessage) => Field m a -> Text -> FormInput m a
- iopt :: Monad m => Field m a -> Text -> FormInput m (Maybe a)

# Documentation

newtype FormInput m a #

Type for a form which parses a value of type `a` with the base monad `m` (usually your `Handler`). Can compose this using its `Applicative` instance.

Constructors

FormInput |
Fields unFormInput :: HandlerSite m -> [Text] -> Env -> FileEnv -> m (Either DText a)

Instances

Monad m => Functor (FormInput m) # |
Methods fmap :: (a -> b) -> FormInput m a -> FormInput m b # (<$) :: a -> FormInput m b -> FormInput m a #
Monad m => Applicative (FormInput m) # |
Methods pure :: a -> FormInput m a # (<*>) :: FormInput m (a -> b) -> FormInput m a -> FormInput m b # (*>) :: FormInput m a -> FormInput m b -> FormInput m b # (<*) :: FormInput m a -> FormInput m b -> FormInput m a #

runInputGet :: MonadHandler m => FormInput m a -> m a #

Run a `FormInput` on the GET parameters (i.e., query string). If parsing fails, calls `invalidArgs`.

runInputGetResult :: MonadHandler m => FormInput m a -> m (FormResult a) #

Run a `FormInput` on the GET parameters (i.e., query string). Does not throw exceptions on failure.

Since 1.4.1

runInputPost :: MonadHandler m => FormInput m a -> m a #

Run a `FormInput` on the POST parameters (i.e., request body). If parsing fails, calls `invalidArgs`.

runInputPostResult :: MonadHandler m => FormInput m a -> m (FormResult a) #

Run a `FormInput` on the POST parameters (i.e., request body). Does not throw exceptions on failure.

ireq #

Arguments

:: (Monad m, RenderMessage (HandlerSite m) FormMessage) |
=> Field m a |
-> Text | name of the field
-> FormInput m a |

Promote a `Field` into a `FormInput`, requiring that the value be present and valid.

iopt :: Monad m => Field m a -> Text -> FormInput m (Maybe a) #

Promote a `Field` into a `FormInput`, with its presence being optional. If the value is present but does not parse correctly, the form will still fail.