From eaffbb93ff040f40834a35c0634401026d18196f Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Wed, 13 Oct 2010 15:21:43 +0200 Subject: [PATCH] mkToForm takes undefined instead of lists of EntityDef --- Yesod/Form.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Yesod/Form.hs b/Yesod/Form.hs index 7001826e..8a4a5a33 100644 --- a/Yesod/Form.hs +++ b/Yesod/Form.hs @@ -48,7 +48,7 @@ import Control.Monad ((<=<)) import Control.Monad.Trans.State import Control.Monad.Trans.Reader import Language.Haskell.TH.Syntax -import Database.Persist.Base (EntityDef (..)) +import Database.Persist.Base (EntityDef (..), PersistEntity (entityDef)) import Data.Char (toUpper, isUpper) import Yesod.Widget import Control.Arrow ((&&&)) @@ -112,9 +112,10 @@ runFormGet f = do gs <- reqGetParams `fmap` getRequest runFormGeneric gs [] f --- | Create 'ToForm' instances for the entities given. In addition to regular 'EntityDef' attributes understood by persistent, it also understands label= and tooltip=. -mkToForm :: [EntityDef] -> Q [Dec] -mkToForm = mapM derive +-- | Create 'ToForm' instances for the given entity. In addition to regular 'EntityDef' attributes understood by persistent, it also understands label= and tooltip=. +mkToForm :: PersistEntity v => v -> Q [Dec] +mkToForm = + fmap return . derive . entityDef where afterPeriod s = case dropWhile (/= '.') s of