guys, i need suggestions to add Update at my Haskell Project. I'm using Yesod.
That's the part of my code that i List all the animals and for each one, a button to delete the animal. How can i make a Update, like this way ?
Thanks.
getListarAnimalR :: Handler Html
getListarAnimalR = do
listaAnm <- runDB $ selectList [] [Asc AnimalsNome]
defaultLayout $ [whamlet|
<h1> Animais cadastrados:
$forall Entity pid animals <- listaAnm
<a href=@{ChecarAnimalR pid}> #{animalsNome animals}
<form method=post action=@{ChecarAnimalR pid}>
<input type="submit" value="Deletar Animal"><br>
|] >> toWidget [lucius|
form { display:inline; }
input { background-color: #ecc; border:0;}
|]
postChecarAnimalR :: AnimalsId -> Handler Html
postChecarAnimalR pid = do
runDB $ delete pid
redirect ListarAnimalR
formAnimal :: Form Animals
formAnimal = renderDivs $ Animals <$>
areq textField "Nome: " Nothing <*>
areq intField "Idade: " Nothing <*>
areq (selectField racas) "Raca" Nothing