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

Safe HaskellNone

Yesod.Form.Bootstrap3

Contents

Description

Helper functions for creating forms when using Bootstrap v3.

Synopsis

Rendering forms

renderBootstrap3 :: Monad m => BootstrapFormLayout -> FormRender m aSource

Render the given form using Bootstrap v3 conventions.

Sample Hamlet for BootstrapHorizontalForm:

  <form .form-horizontal role=form method=post action=@{ActionR} enctype=#{formEnctype}>
    ^{formWidget}
    ^{bootstrapSubmit MsgSubmit}

Since: yesod-form 1.3.8

data BootstrapGridOptions Source

How many bootstrap grid columns should be taken (see BootstrapFormLayout).

Since: yesod-form 1.3.8

Constructors

ColXs !Int 
ColSm !Int 
ColMd !Int 
ColLg !Int 

Field settings

bfs :: RenderMessage site msg => msg -> FieldSettings siteSource

Create a new FieldSettings with the classes that are required by Bootstrap v3.

Since: yesod-form 1.3.8

withPlaceholder :: Text -> FieldSettings site -> FieldSettings siteSource

Add a placeholder attribute to a field. If you need i18n for the placeholder, currently you'll need to do a hack and use getMessageRender manually.

Since: yesod-form 1.3.8

withAutofocus :: FieldSettings site -> FieldSettings siteSource

Add an autofocus attribute to a field.

Since: yesod-form 1.3.8

withLargeInput :: FieldSettings site -> FieldSettings siteSource

Add the input-lg CSS class to a field.

Since: yesod-form 1.3.8

withSmallInput :: FieldSettings site -> FieldSettings siteSource

Add the input-sm CSS class to a field.

Since: yesod-form 1.3.8

Submit button

bootstrapSubmit :: (RenderMessage site msg, HandlerSite m ~ site, MonadHandler m) => BootstrapSubmit msg -> AForm m ()Source

A Bootstrap v3 submit button disguised as a field for convenience. For example, if your form currently is:

 Person <$> areq textField "Name"    Nothing
        <*> areq textField "Surname" Nothing

Then just change it to:

 Person <$> areq textField "Name"    Nothing
        <*> areq textField "Surname" Nothing
        <*  bootstrapSubmit "Register"

(Note that <* is not a typo.)

Alternatively, you may also just create the submit button manually as well in order to have more control over its layout.

Since: yesod-form 1.3.8

mbootstrapSubmit :: (RenderMessage site msg, HandlerSite m ~ site, MonadHandler m) => BootstrapSubmit msg -> MForm m (FormResult (), FieldView site)Source

Same as bootstrapSubmit but for monadic forms. This isn't as useful since you're not going to use renderBootstrap3 anyway.

Since: yesod-form 1.3.8

data BootstrapSubmit msg Source

How the bootstrapSubmit button should be rendered.

Since: yesod-form 1.3.8

Constructors

BootstrapSubmit 

Fields

bsValue :: msg

The text of the submit button.

bsClasses :: Text

Classes added to the button.

bsAttrs :: [(Text, Text)]

Attributes added to the button.

Instances