From 1421bacd49d1ee09c7cd3069da2f1a6ff97540b3 Mon Sep 17 00:00:00 2001 From: DavidM Date: Tue, 21 Jun 2011 18:26:59 -0400 Subject: [PATCH] Invalid input into a field would not repopulate. Like if you put "asdf" into an int field, the page would not refresh with the errant "asdf" in it, because asdf can't be represented as an int. --- Yesod/Form/Fields.hs | 35 ++++++++++++++++++----------------- Yesod/Form/Functions.hs | 9 +++++---- Yesod/Form/Jquery.hs | 6 +++--- Yesod/Form/Nic.hs | 2 +- Yesod/Form/Types.hs | 2 +- 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/Yesod/Form/Fields.hs b/Yesod/Form/Fields.hs index b9ed0e39..741ecbb9 100644 --- a/Yesod/Form/Fields.hs +++ b/Yesod/Form/Fields.hs @@ -128,7 +128,7 @@ intField = Field |] } where - showVal = maybe "" (pack . showI) + showVal = either id (pack . showI) showI x = show (fromIntegral x :: Integer) doubleField :: Monad monad => Field (GGWidget master monad ()) FormMessage Double @@ -143,7 +143,7 @@ doubleField = Field |] } - where showVal = maybe "" (pack . show) + where showVal = either id (pack . show) dayField :: Monad monad => Field (GGWidget master monad ()) FormMessage Day dayField = Field @@ -153,7 +153,7 @@ dayField = Field |] } - where showVal = maybe "" (pack . show) + where showVal = either id (pack . show) timeField :: Monad monad => Field (GGWidget master monad ()) FormMessage TimeOfDay timeField = Field @@ -164,7 +164,7 @@ timeField = Field |] } where - showVal = maybe "" (pack . show . roundFullSeconds) + showVal = either id (pack . show . roundFullSeconds) roundFullSeconds tod = TimeOfDay (todHour tod) (todMin tod) fullSec where @@ -178,7 +178,7 @@ htmlField = Field