simple-form-0.5.0: Forms that configure themselves based on type

Safe HaskellNone
LanguageHaskell98

SimpleForm.Digestive.Combined

Contents

Description

SimpleForm implementation that works along with digestive-functors

The Combined module both renders to Html and also parses input.

Synopsis

Documentation

data SimpleForm r a Source

A form for producing something of type r

type SimpleForm' m a = SimpleForm a (Form Html m a) Source

Convenience type synonym for combined forms

postSimpleForm Source

Arguments

:: Monad m 
=> Renderer 
-> m (Env m)

The digestive-functors input environment

-> SimpleForm' m a

The simple form to render

-> m (Html, Maybe a) 

Render a SimpleForm to Html in the presence of input

This also parses the input to the correct datatype.

The Html is the contents of the form, but you must still wrap it in the actual <form> element.

getSimpleForm Source

Arguments

:: Monad m 
=> Renderer 
-> Maybe a

Default values for the form

-> SimpleForm' m a

The simple form to render

-> m Html 

Render a SimpleForm to Html

This produces the contents of the form, but you must still wrap it in the actual <form> element.

simpleForm' Source

Arguments

:: ToMarkup v 
=> Renderer 
-> (View v, Maybe a)

Results of running a digestive-functors Form

-> SimpleForm a r

The simple form to render

-> (r, Html) 

Render a SimpleForm to Html and get the return value

This produces the contents of the form, but you must still wrap it in the actual <form> element.

Create forms

input Source

Arguments

:: (Eq a, Monad m) 
=> Text

Form element name

-> (r -> Maybe a)

Get value from parsed data

-> (Widget a, Validation a)

Widget and validation to use

-> InputOptions

Other options

-> SimpleForm r (Form Html m a) 

Create an input element for a SimpleForm

input "username" (Just . username) (wdef,vdef) mempty

input_ Source

Arguments

:: (DefaultWidget a, DefaultValidation a, Eq a, Monad m) 
=> Text

Form element name

-> (r -> Maybe a)

Get value from parsed data

-> SimpleForm r (Form Html m a) 

Same as input, but just use the default options

toForm :: ToMarkup h => h -> SimpleForm a () Source

Add some raw markup to a SimpleForm

Subforms

withFields Source

Arguments

:: Monad m 
=> Text

Subview name

-> (r' -> r)

Projection function

-> SimpleForm r (Form Html m a) 
-> SimpleForm r' (Form Html m a) 

Project out some part of the parsed data and name the subview

withFields' Source

Arguments

:: Maybe Text

Optional subview name

-> (r' -> r)

Projection function

-> SimpleForm r a 
-> SimpleForm r' a 

Project out some part of the parsed data (does not add name to subview)

wrap :: (Html -> Html) -> SimpleForm r a -> SimpleForm r a Source

Wrap a SimpleForm in an Html tag

fieldset :: Monad m => Text -> (r' -> r) -> SimpleForm r (Form Html m a) -> SimpleForm r' (Form Html m a) Source

Like withFields, but also wrap in fieldset tag