这是我的代码的一部分,我列出了所有的动物,每个动物,一个删除动物的按钮。 如何以这种方式制作更新?
感谢。
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