From a609f2d046920743fddf1d2b6f61f583bed542bb Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Fri, 13 Aug 2010 16:28:17 +0300 Subject: [PATCH] Remove need to mapFormXml externally --- Yesod/Form.hs | 9 +++++---- hellowidget.hs | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Yesod/Form.hs b/Yesod/Form.hs index 70eb0882..e7c411c6 100644 --- a/Yesod/Form.hs +++ b/Yesod/Form.hs @@ -9,6 +9,7 @@ module Yesod.Form GForm , FormResult (..) , Enctype + , FormFieldSettings (..) -- * Type synonyms , Form , Formlet @@ -48,13 +49,13 @@ import Control.Arrow ((&&&)) import Data.List (group, sort) -- | Display only the actual input widget code, without any decoration. -fieldsToPlain :: [FieldInfo sub y] -> GWidget sub y () -fieldsToPlain = mapM_ fiInput +fieldsToPlain :: FormField sub y a -> Form sub y a +fieldsToPlain = mapFormXml $ mapM_ fiInput -- | Display the label, tooltip, input code and errors in a single row of a -- table. -fieldsToTable :: [FieldInfo sub y] -> GWidget sub y () -fieldsToTable = mapM_ go +fieldsToTable :: FormField sub y a -> Form sub y a +fieldsToTable = mapFormXml $ mapM_ go where go fi = do wrapWidget (fiInput fi) $ \w -> [$hamlet| diff --git a/hellowidget.hs b/hellowidget.hs index b3564e74..b4e3fe73 100644 --- a/hellowidget.hs +++ b/hellowidget.hs @@ -52,7 +52,7 @@ getRootR = applyLayoutW $ flip wrapWidget wrapper $ do addHead [$hamlet|%meta!keywords=haskell|] handleFormR = do - (res, form, enctype) <- runFormPost $ (,,,,,,,,,) + (res, form, enctype) <- runFormPost $ fieldsToTable $ (,,,,,,,,,) <$> stringField (FormFieldSettings "My Field" "Some tooltip info" Nothing Nothing) Nothing <*> stringField ("Another field") (Just "some default text") <*> intField (FormFieldSettings "A number field" "some nums" Nothing Nothing) (Just 5) @@ -84,8 +84,8 @@ textarea.html width:300px height:150px |] - wrapWidget (fieldsToTable form) $ \h -> [$hamlet| -%form!method=post!enctype=$show.enctype$ + wrapWidget form $ \h -> [$hamlet| +%form!method=post!enctype=$enctype$ %table ^h^ %tr