I am running a modified example of http://www.yesodweb.com/book/blog-example-advanced
that previously did not use a parameter id of type DBEntitySchemaId. Since introducing it, I am getting
Handler/Entity.hs:146:34:
Couldn't match type ‘DBEntitySchemaId -> Route App’
with ‘Route (HandlerSite (WidgetT App IO))’
Expected type: WidgetT
App IO ((DBEntitySchemaId -> Route App) -> [(Text, Text)] -> Text)
Actual type: WidgetT
App
IO
(Route (HandlerSite (WidgetT App IO)) -> [(Text, Text)] -> Text)
In the first argument of ‘(>>=)’, namely ‘getUrlRenderParams’
In a stmt of a 'do' block:
(getUrlRenderParams
>>=
(\ urender_akdM
-> (asWidgetT GHC.Base.. toWidget)
(toHtml (\ u_akdN -> urender_akdM u_akdN [] EntityR))))
which refers to the line using the defaultLayout. The relevant code is:
getEntityR :: DBEntitySchemaId -> Handler Html
getEntityR id = do
oldEntities <- runDB $ selectList [DBEntityDbentitySchemaId ==. id] []
fields <- runDB $ selectList [DBFieldDbentitySchemaId ==. id, DBFieldFieldTypeId ==. (toSqlKey 1)] []
mauthId <- maybeAuthId
((res, widget), enctype) <- runFormPost (form fields)
case (mauthId,res) of
(Just userId, FormSuccess (attributeValues)) -> do
setMessageI $ MsgSubmittedKarma
let entity = DBEntity "Test" id
entId <- runDB $ insert entity
let fieldsNVals = zip fields attributeValues
let einfuegen field attributeValue = case (field, attributeValue) of
((Entity fldId _), (FormSuccess val)) -> do
a <- runDB $ insert (Attribute {attributeEntityId = entId, attributeDbfieldId = fldId, attributeStringValue = val})
return (Just a)
_ -> return Nothing
_ <- forM fieldsNVals (\(field, attributeValue) -> einfuegen field attributeValue)
redirect $ (EntityR id)
_ -> do
--render <- getUrlRenderParams
--return $ renderHtml $ [hamlet|
defaultLayout [whamlet|
$if null oldEntities
<p>There are no entities
$else
<ul>
$forall Entity entityId entity <- oldEntities
<li>
<p>#{dBEntityName entity}
$if mauthId == Nothing
<form method=post action=@{EntityR} enctype=#{enctype}>
<input type=submit value=_{MsgPleaseLogin}>
$else
<form method=post action=@{EntityR} enctype=#{enctype}>
^{widget}
<input type=submit>
|]
What I already tried was changing whamlet to hamlet and adding some lines of code from here (commented out)
Trying to send an email in yesod using hamlet
and changing
[whamlet|
to
[whamlet|@{getEntityR}/#{id}|
and
[whamlet||@?{urlParams id}|
and some variations of this inspired by
Render url with query parameters https://groups.google.com/forum/#!topic/yesodweb/q1gtkOgM32I
I assume there is only a small modification to make. However my understanding of whamlet/hamlet is not too great. So I am posting this in case it is a trivial problem. I fully understand that I need to put in more work, I am just having trouble googling my problem. So please bear with me.
After modifying your route you forgot to pass newly added parameter into @{EntityR}
interpolation, something like this: @{EntityR param}
.