Safe Haskell | None |
---|
Helper functions for creating forms when using Bootstrap v3.
- renderBootstrap3 :: Monad m => BootstrapFormLayout -> FormRender m a
- data BootstrapFormLayout
- data BootstrapGridOptions
- bfs :: RenderMessage site msg => msg -> FieldSettings site
- withPlaceholder :: Text -> FieldSettings site -> FieldSettings site
- withAutofocus :: FieldSettings site -> FieldSettings site
- withLargeInput :: FieldSettings site -> FieldSettings site
- withSmallInput :: FieldSettings site -> FieldSettings site
- bootstrapSubmit :: (RenderMessage site msg, HandlerSite m ~ site, MonadHandler m) => BootstrapSubmit msg -> AForm m ()
- mbootstrapSubmit :: (RenderMessage site msg, HandlerSite m ~ site, MonadHandler m) => BootstrapSubmit msg -> MForm m (FormResult (), FieldView site)
- data BootstrapSubmit msg = BootstrapSubmit {}
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 BootstrapFormLayout Source
The layout used for the bootstrap form.
Since: yesod-form 1.3.8
Show BootstrapFormLayout |
data BootstrapGridOptions Source
How many bootstrap grid columns should be taken (see
BootstrapFormLayout
).
Since: yesod-form 1.3.8
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
Show msg => Show (BootstrapSubmit msg) | |
IsString msg => IsString (BootstrapSubmit msg) |