Render the given form using Bootstrap v3 conventions.
Since: yesod-form 1.3.8
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Moduleyesod-form-1.7.9Haskell2010
Helper functions for creating forms when using Bootstrap 3.
<input> tags in Bootstrap 3 require the form-control class,
and so they need modified FieldSettings to display correctly.
When creating your forms, use the bfs function to add this class:
personForm :: AForm Handler Person
personForm = Person
<$> areq textField (bfs ("Name" :: Text)) Nothing
<*> areq textField (bfs ("Surname" :: Text)) NothingThat form can then be rendered into a widget using the renderBootstrap3 function. Here, the form is laid out vertically using BootstrapBasicForm:
(formWidget, formEnctype) <- generateFormPost $ renderBootstrap3 BootstrapBasicForm personFormAnd then used in Hamlet:
<form role=form method=post action=@{ActionR} enctype=#{formEnctype}>
^{formWidget}
<button type="submit" .btn .btn-default>SubmitYesod.Form.Bootstrap3 also supports horizontal, grid based forms. These forms require additional markup for the submit tag, which is provided by the bootstrapSubmit function:
personForm :: AForm Handler Person
personForm = Person
<$> areq textField MsgName Nothing
<*> areq textField MsgSurname Nothing
<* bootstrapSubmit (BootstrapSubmit MsgSubmit "btn-default" [("attribute-name","attribute-value")])
-- Note: bootstrapSubmit works with all BootstrapFormLayouts, but provides the additional markup required for Bootstrap's horizontal forms.That form can be rendered with specific grid spacing:
(formWidget, formEnctype) <- generateFormPost $ renderBootstrap3 (BootstrapHorizontalForm (ColSm 0) (ColSm 4) (ColSm 0) (ColSm 6)) personFormAnd then used in Hamlet. Note the additional form-horizontal class on the form, and that a manual submit tag isn't required:
<form .form-horizontal role=form method=post action=@{ActionR} enctype=#{formEnctype}>
^{formWidget}Render the given form using Bootstrap v3 conventions.
Since: yesod-form 1.3.8
The layout used for the bootstrap form.
Since: yesod-form 1.3.8
BootstrapBasicFormA form with labels and inputs listed vertically. See http://getbootstrap.com/css/#forms-example
BootstrapInlineFormA form whose <inputs> are laid out horizontally (displayed as inline-block). For this layout, <label>s are still added to the HTML, but are hidden from display. When using this layout, you must add the form-inline class to your form tag. See http://getbootstrap.com/css/#forms-inline
BootstrapHorizontalFormbflLabelOffset :: !BootstrapGridOptionsThe left offset of the <label>.
bflLabelSize :: !BootstrapGridOptionsThe number of grid columns the <label> should use.
bflInputOffset :: !BootstrapGridOptionsThe left offset of the <input> from its <label>.
bflInputSize :: !BootstrapGridOptionsThe number of grid columns the <input> should use.
Show BootstrapFormLayoutDefined in yesod-form-1.7.9 · Yesod.Form.Bootstrap3How many bootstrap grid columns should be taken (see BootstrapFormLayout).
Since: yesod-form 1.3.8
Eq BootstrapGridOptionsDefined in yesod-form-1.7.9 · Yesod.Form.Bootstrap3Ord BootstrapGridOptionsDefined in yesod-form-1.7.9 · Yesod.Form.Bootstrap3Show BootstrapGridOptionsDefined in yesod-form-1.7.9 · Yesod.Form.Bootstrap3This module comes with several methods to help customize your Bootstrap 3 <input>s.
These functions can be chained together to apply several properties to an input:
userForm :: AForm Handler UserForm
userForm = UserForm
<$> areq textField nameSettings Nothing
where nameSettings = withAutofocus $
withPlaceholder "First name" $
(bfs ("Name" :: Text))Create a new FieldSettings with the form-control class that is
required by Bootstrap v3.
Since: yesod-form 1.3.8
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
Add an autofocus attribute to a field.
Since: yesod-form 1.3.8
Add the input-lg CSS class to a field.
Since: yesod-form 1.3.8
Add the input-sm CSS class to a field.
Since: yesod-form 1.3.8
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" NothingThen just change it to:
Person <$> areq textField "Name" Nothing
<*> areq textField "Surname" Nothing
<* bootstrapSubmit ("Register" :: BootstrapSubmit Text)(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
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
How the bootstrapSubmit button should be rendered.
Since: yesod-form 1.3.8
Show msg => Show (BootstrapSubmit msg)Defined in yesod-form-1.7.9 · Yesod.Form.Bootstrap3IsString msg => IsString (BootstrapSubmit msg)Defined in yesod-form-1.7.9 · Yesod.Form.Bootstrap3