haskellyesodyesod-forms

use BootstrapHorizontalForm in yesod


I intend use a BootstrapHorizontalForm, use how example this guide, my code:

the form

churchForm :: Maybe Church -> AForm Handler (Church,Maybe FileInfo)
churchForm mc = (,) <$>
(Church
 <$> areq textField (bfs MsgName) (churchName <$> mc)
 <*  bootstrapSubmit (BootstrapSubmit MsgCreateAction "btn-default" [("attribute-name","attribute-value")])

the GET method

getChurchNewR :: Handler Html
getChurchNewR = do
(widget, enctype) <- generateFormPost $
                   renderBootstrap3 (BootstrapHorizontalForm (ColSm 0) (ColSm 4) (ColSm 0) (ColSm 6))
                   (churchForm Nothing)
  defaultLayout $ do
    msgAction = MsgCreateAction
    actionR = ChurchNewR
    mPath = Nothing
$(widgetFile "church/church")

but have this error:

Handler/Church.hs:63:67: Not in scope: data constructor ‘ColSm’

thanks for you help


Solution

  • This looks like a missing import. Check that you actually import CpmSm at the top of your file.

    This import could be of the form:

    import Yesod.Form.Bootstrap3 (BootstrapGridOptions (ColSm))
    

    or

    import Yesod.Form.Bootstrap3 (BootstrapGridOptions (..))
    

    or even

    import Yesod.Form.Bootstrap3
    

    If that doesn't sound familiar, you can take a look at the modules chapter from Learn Yourself a Haskell to know more about imports.