yesod-form 1.4.1 → 1.4.1.1
raw patch · 2 files changed
+76/−21 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Yesod.Form.Bootstrap3: bflInputOffset :: BootstrapFormLayout -> !BootstrapGridOptions
- Yesod.Form.Bootstrap3: bflInputSize :: BootstrapFormLayout -> !BootstrapGridOptions
- Yesod.Form.Bootstrap3: bflLabelOffset :: BootstrapFormLayout -> !BootstrapGridOptions
- Yesod.Form.Bootstrap3: bflLabelSize :: BootstrapFormLayout -> !BootstrapGridOptions
- Yesod.Form.Bootstrap3: bsAttrs :: BootstrapSubmit msg -> [(Text, Text)]
- Yesod.Form.Bootstrap3: bsClasses :: BootstrapSubmit msg -> Text
- Yesod.Form.Bootstrap3: bsValue :: BootstrapSubmit msg -> msg
- Yesod.Form.Bootstrap3: instance Eq BootstrapGridOptions
- Yesod.Form.Bootstrap3: instance IsString msg => IsString (BootstrapSubmit msg)
- Yesod.Form.Bootstrap3: instance Ord BootstrapGridOptions
- Yesod.Form.Bootstrap3: instance Show BootstrapFormLayout
- Yesod.Form.Bootstrap3: instance Show BootstrapGridOptions
- Yesod.Form.Bootstrap3: instance Show msg => Show (BootstrapSubmit msg)
- Yesod.Form.Fields: instance Eq Textarea
- Yesod.Form.Fields: instance FromJSON Textarea
- Yesod.Form.Fields: instance Ord Textarea
- Yesod.Form.Fields: instance PersistField Textarea
- Yesod.Form.Fields: instance PersistFieldSql Textarea
- Yesod.Form.Fields: instance Read Textarea
- Yesod.Form.Fields: instance Show Textarea
- Yesod.Form.Fields: instance ToJSON Textarea
- Yesod.Form.Fields: instance ToMarkup Textarea
- Yesod.Form.Fields: olOptions :: OptionList a -> [Option a]
- Yesod.Form.Fields: olReadExternal :: OptionList a -> Text -> Maybe a
- Yesod.Form.Fields: optionDisplay :: Option a -> Text
- Yesod.Form.Fields: optionExternalValue :: Option a -> Text
- Yesod.Form.Fields: optionInternalValue :: Option a -> a
- Yesod.Form.Fields: unTextarea :: Textarea -> Text
- Yesod.Form.Input: instance Monad m => Applicative (FormInput m)
- Yesod.Form.Input: instance Monad m => Functor (FormInput m)
- Yesod.Form.Input: unFormInput :: FormInput m a -> HandlerSite m -> [Text] -> Env -> FileEnv -> m (Either DText a)
- Yesod.Form.Jquery: instance Default JqueryDaySettings
- Yesod.Form.Jquery: jdsChangeMonth :: JqueryDaySettings -> Bool
- Yesod.Form.Jquery: jdsChangeYear :: JqueryDaySettings -> Bool
- Yesod.Form.Jquery: jdsNumberOfMonths :: JqueryDaySettings -> Either Int (Int, Int)
- Yesod.Form.Jquery: jdsYearRange :: JqueryDaySettings -> String
- Yesod.Form.Types: fieldEnctype :: Field m a -> Enctype
- Yesod.Form.Types: fieldParse :: Field m a -> [Text] -> [FileInfo] -> m (Either (SomeMessage (HandlerSite m)) (Maybe a))
- Yesod.Form.Types: fieldView :: Field m a -> FieldViewFunc m a
- Yesod.Form.Types: fsAttrs :: FieldSettings master -> [(Text, Text)]
- Yesod.Form.Types: fsId :: FieldSettings master -> Maybe Text
- Yesod.Form.Types: fsLabel :: FieldSettings master -> SomeMessage master
- Yesod.Form.Types: fsName :: FieldSettings master -> Maybe Text
- Yesod.Form.Types: fsTooltip :: FieldSettings master -> Maybe (SomeMessage master)
- Yesod.Form.Types: fvErrors :: FieldView site -> Maybe Markup
- Yesod.Form.Types: fvId :: FieldView site -> Text
- Yesod.Form.Types: fvInput :: FieldView site -> WidgetT site IO ()
- Yesod.Form.Types: fvLabel :: FieldView site -> Markup
- Yesod.Form.Types: fvRequired :: FieldView site -> Bool
- Yesod.Form.Types: fvTooltip :: FieldView site -> Maybe Markup
- Yesod.Form.Types: instance (Monad m, Monoid a) => Monoid (AForm m a)
- Yesod.Form.Types: instance Applicative FormResult
- Yesod.Form.Types: instance Bounded Enctype
- Yesod.Form.Types: instance Enum Enctype
- Yesod.Form.Types: instance Eq Enctype
- Yesod.Form.Types: instance Eq FormMessage
- Yesod.Form.Types: instance Functor FormResult
- Yesod.Form.Types: instance IsString (FieldSettings a)
- Yesod.Form.Types: instance Monad m => Applicative (AForm m)
- Yesod.Form.Types: instance Monad m => Functor (AForm m)
- Yesod.Form.Types: instance MonadTrans AForm
- Yesod.Form.Types: instance Monoid Enctype
- Yesod.Form.Types: instance Monoid m => Monoid (FormResult m)
- Yesod.Form.Types: instance Read FormMessage
- Yesod.Form.Types: instance Show FormMessage
- Yesod.Form.Types: instance Show Ints
- Yesod.Form.Types: instance Show a => Show (FormResult a)
- Yesod.Form.Types: instance ToMarkup Enctype
- Yesod.Form.Types: unAForm :: AForm m a -> (HandlerSite m, [Text]) -> Maybe (Env, FileEnv) -> Ints -> m (FormResult a, [FieldView (HandlerSite m)] -> [FieldView (HandlerSite m)], Ints, Enctype)
+ Yesod.Form.Bootstrap3: [bflInputOffset] :: BootstrapFormLayout -> !BootstrapGridOptions
+ Yesod.Form.Bootstrap3: [bflInputSize] :: BootstrapFormLayout -> !BootstrapGridOptions
+ Yesod.Form.Bootstrap3: [bflLabelOffset] :: BootstrapFormLayout -> !BootstrapGridOptions
+ Yesod.Form.Bootstrap3: [bflLabelSize] :: BootstrapFormLayout -> !BootstrapGridOptions
+ Yesod.Form.Bootstrap3: [bsAttrs] :: BootstrapSubmit msg -> [(Text, Text)]
+ Yesod.Form.Bootstrap3: [bsClasses] :: BootstrapSubmit msg -> Text
+ Yesod.Form.Bootstrap3: [bsValue] :: BootstrapSubmit msg -> msg
+ Yesod.Form.Bootstrap3: instance Data.String.IsString msg => Data.String.IsString (Yesod.Form.Bootstrap3.BootstrapSubmit msg)
+ Yesod.Form.Bootstrap3: instance GHC.Classes.Eq Yesod.Form.Bootstrap3.BootstrapGridOptions
+ Yesod.Form.Bootstrap3: instance GHC.Classes.Ord Yesod.Form.Bootstrap3.BootstrapGridOptions
+ Yesod.Form.Bootstrap3: instance GHC.Show.Show Yesod.Form.Bootstrap3.BootstrapFormLayout
+ Yesod.Form.Bootstrap3: instance GHC.Show.Show Yesod.Form.Bootstrap3.BootstrapGridOptions
+ Yesod.Form.Bootstrap3: instance GHC.Show.Show msg => GHC.Show.Show (Yesod.Form.Bootstrap3.BootstrapSubmit msg)
+ Yesod.Form.Fields: [olOptions] :: OptionList a -> [Option a]
+ Yesod.Form.Fields: [olReadExternal] :: OptionList a -> Text -> Maybe a
+ Yesod.Form.Fields: [optionDisplay] :: Option a -> Text
+ Yesod.Form.Fields: [optionExternalValue] :: Option a -> Text
+ Yesod.Form.Fields: [optionInternalValue] :: Option a -> a
+ Yesod.Form.Fields: [unTextarea] :: Textarea -> Text
+ Yesod.Form.Fields: instance Data.Aeson.Types.Class.FromJSON Yesod.Form.Fields.Textarea
+ Yesod.Form.Fields: instance Data.Aeson.Types.Class.ToJSON Yesod.Form.Fields.Textarea
+ Yesod.Form.Fields: instance Database.Persist.Class.PersistField.PersistField Yesod.Form.Fields.Textarea
+ Yesod.Form.Fields: instance Database.Persist.Sql.Class.PersistFieldSql Yesod.Form.Fields.Textarea
+ Yesod.Form.Fields: instance GHC.Classes.Eq Yesod.Form.Fields.Textarea
+ Yesod.Form.Fields: instance GHC.Classes.Ord Yesod.Form.Fields.Textarea
+ Yesod.Form.Fields: instance GHC.Read.Read Yesod.Form.Fields.Textarea
+ Yesod.Form.Fields: instance GHC.Show.Show Yesod.Form.Fields.Textarea
+ Yesod.Form.Fields: instance Text.Blaze.ToMarkup Yesod.Form.Fields.Textarea
+ Yesod.Form.Input: [unFormInput] :: FormInput m a -> HandlerSite m -> [Text] -> Env -> FileEnv -> m (Either DText a)
+ Yesod.Form.Input: instance GHC.Base.Monad m => GHC.Base.Applicative (Yesod.Form.Input.FormInput m)
+ Yesod.Form.Input: instance GHC.Base.Monad m => GHC.Base.Functor (Yesod.Form.Input.FormInput m)
+ Yesod.Form.Jquery: [jdsChangeMonth] :: JqueryDaySettings -> Bool
+ Yesod.Form.Jquery: [jdsChangeYear] :: JqueryDaySettings -> Bool
+ Yesod.Form.Jquery: [jdsNumberOfMonths] :: JqueryDaySettings -> Either Int (Int, Int)
+ Yesod.Form.Jquery: [jdsYearRange] :: JqueryDaySettings -> String
+ Yesod.Form.Jquery: instance Data.Default.Class.Default Yesod.Form.Jquery.JqueryDaySettings
+ Yesod.Form.Types: [fieldEnctype] :: Field m a -> Enctype
+ Yesod.Form.Types: [fieldParse] :: Field m a -> [Text] -> [FileInfo] -> m (Either (SomeMessage (HandlerSite m)) (Maybe a))
+ Yesod.Form.Types: [fieldView] :: Field m a -> FieldViewFunc m a
+ Yesod.Form.Types: [fsAttrs] :: FieldSettings master -> [(Text, Text)]
+ Yesod.Form.Types: [fsId] :: FieldSettings master -> Maybe Text
+ Yesod.Form.Types: [fsLabel] :: FieldSettings master -> SomeMessage master
+ Yesod.Form.Types: [fsName] :: FieldSettings master -> Maybe Text
+ Yesod.Form.Types: [fsTooltip] :: FieldSettings master -> Maybe (SomeMessage master)
+ Yesod.Form.Types: [fvErrors] :: FieldView site -> Maybe Markup
+ Yesod.Form.Types: [fvId] :: FieldView site -> Text
+ Yesod.Form.Types: [fvInput] :: FieldView site -> WidgetT site IO ()
+ Yesod.Form.Types: [fvLabel] :: FieldView site -> Markup
+ Yesod.Form.Types: [fvRequired] :: FieldView site -> Bool
+ Yesod.Form.Types: [fvTooltip] :: FieldView site -> Maybe Markup
+ Yesod.Form.Types: [unAForm] :: AForm m a -> (HandlerSite m, [Text]) -> Maybe (Env, FileEnv) -> Ints -> m (FormResult a, [FieldView (HandlerSite m)] -> [FieldView (HandlerSite m)], Ints, Enctype)
+ Yesod.Form.Types: instance (GHC.Base.Monad m, GHC.Base.Monoid a) => GHC.Base.Monoid (Yesod.Form.Types.AForm m a)
+ Yesod.Form.Types: instance Control.Monad.Trans.Class.MonadTrans Yesod.Form.Types.AForm
+ Yesod.Form.Types: instance Data.String.IsString (Yesod.Form.Types.FieldSettings a)
+ Yesod.Form.Types: instance GHC.Base.Applicative Yesod.Form.Types.FormResult
+ Yesod.Form.Types: instance GHC.Base.Functor Yesod.Form.Types.FormResult
+ Yesod.Form.Types: instance GHC.Base.Monad m => GHC.Base.Applicative (Yesod.Form.Types.AForm m)
+ Yesod.Form.Types: instance GHC.Base.Monad m => GHC.Base.Functor (Yesod.Form.Types.AForm m)
+ Yesod.Form.Types: instance GHC.Base.Monoid Yesod.Form.Types.Enctype
+ Yesod.Form.Types: instance GHC.Base.Monoid m => GHC.Base.Monoid (Yesod.Form.Types.FormResult m)
+ Yesod.Form.Types: instance GHC.Classes.Eq Yesod.Form.Types.Enctype
+ Yesod.Form.Types: instance GHC.Classes.Eq Yesod.Form.Types.FormMessage
+ Yesod.Form.Types: instance GHC.Enum.Bounded Yesod.Form.Types.Enctype
+ Yesod.Form.Types: instance GHC.Enum.Enum Yesod.Form.Types.Enctype
+ Yesod.Form.Types: instance GHC.Read.Read Yesod.Form.Types.FormMessage
+ Yesod.Form.Types: instance GHC.Show.Show Yesod.Form.Types.FormMessage
+ Yesod.Form.Types: instance GHC.Show.Show Yesod.Form.Types.Ints
+ Yesod.Form.Types: instance GHC.Show.Show a => GHC.Show.Show (Yesod.Form.Types.FormResult a)
+ Yesod.Form.Types: instance Text.Blaze.ToMarkup Yesod.Form.Types.Enctype
- Yesod.Form.Functions: convertField :: Functor m => (a -> b) -> (b -> a) -> Field m a -> Field m b
+ Yesod.Form.Functions: convertField :: (Functor m) => (a -> b) -> (b -> a) -> Field m a -> Field m b
- Yesod.Form.Types: type FieldViewFunc m a = Text -> Text -> [(Text, Text)] -> Either Text a -> Bool -> WidgetT (HandlerSite m) IO ()
+ Yesod.Form.Types: type FieldViewFunc m a = Text ID -> Text Name -> [(Text, Text)] Attributes -> Either Text a Either (invalid text) or (legitimate result) -> Bool Required? -> WidgetT (HandlerSite m) IO ()
Files
- Yesod/Form/Bootstrap3.hs +75/−20
- yesod-form.cabal +1/−1
Yesod/Form/Bootstrap3.hs view
@@ -1,13 +1,22 @@ {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE OverloadedStrings #-}--- | Helper functions for creating forms when using Bootstrap v3.+-- | Helper functions for creating forms when using <http://getbootstrap.com/ Bootstrap 3>.+--+ module Yesod.Form.Bootstrap3- ( -- * Rendering forms+ ( -- * Example: Rendering a basic form+ -- $example++ -- * Example: Rendering a horizontal form+ -- $example2++ -- * Rendering forms renderBootstrap3 , BootstrapFormLayout(..) , BootstrapGridOptions(..) -- * Field settings+ -- $fieldSettings , bfs , withPlaceholder , withAutofocus@@ -30,7 +39,7 @@ import Yesod.Form.Types import Yesod.Form.Functions --- | Create a new 'FieldSettings' with the classes that are+-- | Create a new 'FieldSettings' with the @form-control@ class that is -- required by Bootstrap v3. -- -- Since: yesod-form 1.3.8@@ -126,25 +135,19 @@ -- -- Since: yesod-form 1.3.8 data BootstrapFormLayout =- BootstrapBasicForm- | BootstrapInlineForm+ BootstrapBasicForm -- ^ A form with labels and inputs listed vertically. See <http://getbootstrap.com/css/#forms-example>+ | BootstrapInlineForm -- ^ A 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> | BootstrapHorizontalForm- { bflLabelOffset :: !BootstrapGridOptions- , bflLabelSize :: !BootstrapGridOptions- , bflInputOffset :: !BootstrapGridOptions- , bflInputSize :: !BootstrapGridOptions- }+ { bflLabelOffset :: !BootstrapGridOptions -- ^ The left <http://getbootstrap.com/css/#grid-offsetting offset> of the @\<label>@.+ , bflLabelSize :: !BootstrapGridOptions -- ^ The number of grid columns the @\<label>@ should use.+ , bflInputOffset :: !BootstrapGridOptions -- ^ The left <http://getbootstrap.com/css/#grid-offsetting offset> of the @\<input>@ from its @\<label>@.+ , bflInputSize :: !BootstrapGridOptions -- ^ The number of grid columns the @\<input>@ should use.+ } -- ^ A form laid out using the Bootstrap grid, with labels in the left column and inputs on the right. When using this layout, you must add the @form-horizontal@ class to your form tag. Bootstrap requires additional markup for the submit button for horizontal forms; you can use 'bootstrapSubmit' in your form or write the markup manually. See <http://getbootstrap.com/css/#forms-horizontal> deriving (Show) -- | 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 renderBootstrap3 :: Monad m => BootstrapFormLayout -> FormRender m a renderBootstrap3 formLayout aform fragment = do@@ -200,9 +203,9 @@ { bsValue :: msg -- ^ The text of the submit button. , bsClasses :: Text- -- ^ Classes added to the @<button>@.+ -- ^ Classes added to the @\<button>@. , bsAttrs :: [(Text, Text)]- -- ^ Attributes added to the @<button>@.+ -- ^ Attributes added to the @\<button>@. } deriving (Show) instance IsString msg => IsString (BootstrapSubmit msg) where@@ -219,9 +222,9 @@ -- -- > Person <$> areq textField "Name" Nothing -- > <*> areq textField "Surname" Nothing--- > <* bootstrapSubmit "Register"+-- > <* bootstrapSubmit ("Register" :: BootstrapSubmit Text) ----- (Note that @<*@ is not a typo.)+-- (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@@ -260,3 +263,55 @@ -- 'bootstrapSubmit' outside 'renderBootstrap3'. bootstrapSubmitId :: Text bootstrapSubmitId = "b:ootstrap___unique__:::::::::::::::::submit-id"++-- $example+-- @\<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)) Nothing+--+-- That 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 personForm+--+-- And then used in Hamlet:+--+-- > <form role=form method=post action=@{ActionR} enctype=#{formEnctype}>+-- > ^{formWidget}+-- > <button type="submit" .btn .btn-default>Submit++-- $example2+-- Yesod.Form.Bootstrap3 also supports <http://getbootstrap.com/css/#forms-horizontal 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)) personForm+--+-- And 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}++-- $fieldSettings+-- This 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))
yesod-form.cabal view
@@ -1,5 +1,5 @@ name: yesod-form-version: 1.4.1+version: 1.4.1.1 license: MIT license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>