Skip to content

Instantly share code, notes, and snippets.

@ptkato
Created December 2, 2015 15:40
Show Gist options
  • Save ptkato/3c397cbf5c285fd1c421 to your computer and use it in GitHub Desktop.
Save ptkato/3c397cbf5c285fd1c421 to your computer and use it in GitHub Desktop.
formAv :: Form Avaliacao
formAv = renderDivs $ Avaliacao <$>
areq intField "Nota" Nothing <*>
pure kludge <*>
areq (selectField lv) "Livro:" Nothing <*>
areq textField "Avaliação: " Nothing
kludge = case us of
Just (Entity pid user) -> pid
Nothing -> redirect LoginR
us = do
xy <- lookupSession "_ID"
case xy of
Just x -> runDB $ selectFirst [UsuarioNome ==. x] []
Nothing -> redirect LoginR
lv = do
entidades <- runDB $ selectList [] [Asc LivroNm_Livro]
optionsPairs $ fmap(\ent -> (livroNm_Livro $ entityVal ent, entityKey ent)) entidades
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment