Safe Haskell | None |
---|---|
Language | Haskell98 |
- runJSONForm :: MonadHandler m => FormInput m a -> m a
- jsonField :: (Monad m, FromJSON a) => RenderMessage (HandlerSite m) FormMessage => Field m a
The example of use
data Offer = Offer { name :: Text , description Text , supplier :: SupplierId , category :: CategoryId , tags :: [TagId] , images :: [Image] , variants :: [Variant] , active :: Bool }
offer <- runJSONForm $ Offer <$> ireq textField "name" <*> ireq textField "description" <*> ireq jsonField "supplier" <*> ireq jsonField "category") <*> ireq jsonField "tags") <*> ireq jsonField "images" <*> (fmap nub $ ireq jsonField "variants") <*> ireq boolField "active"
Functions
runJSONForm :: MonadHandler m => FormInput m a -> m a Source
Run JSON form
jsonField :: (Monad m, FromJSON a) => RenderMessage (HandlerSite m) FormMessage => Field m a Source
Obtain JSON field from json request