Add some docs for MassInput

This commit is contained in:
Michael Snoyman 2016-02-01 11:31:10 +02:00
parent 3d8c91bae6
commit 5709040dcd

View File

@ -3,6 +3,8 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE CPP#-}
-- | A module providing a means of creating multiple input forms, such as a
-- list of 0 or more recipients.
module Yesod.Form.MassInput
( inputList
, massDivs
@ -40,11 +42,19 @@ up i = do
IntCons _ is' -> put is' >> newFormIdent >> return ()
up $ i - 1
-- | Generate a form that accepts 0 or more values from the user, allowing the
-- user to specify that a new row is necessary.
inputList :: (m ~ HandlerT site IO, xml ~ WidgetT site IO (), RenderMessage site FormMessage)
=> Html
-- ^ label for the form
-> ([[FieldView site]] -> xml)
-- ^ how to display the rows, usually either 'massDivs' or 'massTable'
-> (Maybe a -> AForm (HandlerT site IO) a)
-> (Maybe [a] -> AForm (HandlerT site IO) [a])
-- ^ display a single row of the form, where @Maybe a@ gives the
-- previously submitted value
-> Maybe [a]
-- ^ default initial values for the form
-> AForm (HandlerT site IO) [a]
inputList label fixXml single mdef = formToAForm $ do
theId <- lift newIdent
down 1