diff --git a/yesod-form/Yesod/Form/Fields.hs b/yesod-form/Yesod/Form/Fields.hs index 9a9c04b6..53ef9903 100644 --- a/yesod-form/Yesod/Form/Fields.hs +++ b/yesod-form/Yesod/Form/Fields.hs @@ -67,7 +67,7 @@ import Text.Blaze.Renderer.String (renderHtml) import qualified Data.ByteString as S import qualified Data.ByteString.Lazy as L import Data.Text (Text, unpack, pack) -import qualified Data.Text as T (null) +import qualified Data.Text as T import qualified Data.Text.Read import Control.Monad.Trans.Class (lift) @@ -113,7 +113,7 @@ intField = Field , fieldView = \theId name theClass val isReq -> addHamlet [HAMLET|\ - + |] } where @@ -129,7 +129,7 @@ doubleField = Field , fieldView = \theId name theClass val isReq -> addHamlet [HAMLET|\ - + |] } where showVal = either id (pack . show) @@ -139,7 +139,7 @@ dayField = Field { fieldParse = blank $ parseDate . unpack , fieldView = \theId name theClass val isReq -> addHamlet [HAMLET|\ - + |] } where showVal = either id (pack . show) @@ -149,7 +149,7 @@ timeField = Field { fieldParse = blank $ parseTime . unpack , fieldView = \theId name theClass val isReq -> addHamlet [HAMLET|\ - + |] } where @@ -165,7 +165,7 @@ htmlField = Field , fieldView = \theId name theClass val _isReq -> addHamlet -- FIXME: There was a class="html" attribute, for what purpose? [HAMLET|\ -#{showVal val} +#{showVal val} |] } where showVal = either id (pack . renderHtml) @@ -193,7 +193,7 @@ textareaField = Field { fieldParse = blank $ Right . Textarea , fieldView = \theId name theClass val _isReq -> addHamlet [HAMLET|\ -#{either id unTextarea val} +#{either id unTextarea val} |] } @@ -202,7 +202,7 @@ hiddenField = Field { fieldParse = blank $ Right , fieldView = \theId name theClass val _isReq -> addHamlet [HAMLET|\ - + |] } @@ -211,7 +211,7 @@ textField = Field { fieldParse = blank $ Right , fieldView = \theId name theClass val isReq -> [WHAMLET| - + |] } @@ -220,7 +220,7 @@ passwordField = Field { fieldParse = blank $ Right , fieldView = \theId name theClass val isReq -> addHamlet [HAMLET|\ - + |] } @@ -270,7 +270,7 @@ emailField = Field else Left $ MsgInvalidEmail s , fieldView = \theId name theClass val isReq -> addHamlet [HAMLET|\ - + |] } @@ -280,7 +280,7 @@ searchField autoFocus = Field { fieldParse = blank Right , fieldView = \theId name theClass val isReq -> do [WHAMLET|\ - + |] when autoFocus $ do -- we want this javascript to be placed immediately after the field @@ -300,7 +300,7 @@ urlField = Field Just _ -> Right s , fieldView = \theId name theClass val isReq -> [WHAMLET| - + |] } @@ -311,12 +311,12 @@ selectField' :: (Eq a, RenderMessage master FormMessage) => GHandlerT sub master selectField' = selectFieldHelper (\theId name inside -> [WHAMLET|^{inside}|]) -- outside (\_theId _name isSel -> [WHAMLET|_{MsgSelectNone}|]) -- onOpt - (\_theId _name theClass value isSel text -> [WHAMLET|#{text}|]) -- inside + (\_theId _name theClass value isSel text -> [WHAMLET|#{text}|]) -- inside multiSelectField :: (Show a, Eq a, RenderMessage master FormMessage) => [(Text, a)] -> Field sub master [a] multiSelectField = multiSelectFieldHelper (\theId name inside -> [WHAMLET|^{inside}|]) - (\_theId _name theClass value isSel text -> [WHAMLET|#{text}|]) + (\_theId _name theClass value isSel text -> [WHAMLET|#{text}|]) radioField :: (Eq a, RenderMessage master FormMessage) => [(Text, a)] -> Field sub master a radioField = radioField' . optionsPairs @@ -331,7 +331,7 @@ radioField' = selectFieldHelper |]) (\theId name theClass value isSel text -> [WHAMLET| - + #{text} |]) @@ -340,14 +340,14 @@ boolField = Field { fieldParse = return . boolParser , fieldView = \theId name theClass val isReq -> [WHAMLET| $if not isReq - + _{MsgSelectNone} - + _{MsgBoolYes} - + _{MsgBoolNo} |] } @@ -363,7 +363,7 @@ boolField = Field multiSelectFieldHelper :: (Show a, Eq a) => (Text -> Text -> GWidget sub master () -> GWidget sub master ()) - -> (Text -> Text -> Text -> Text -> Bool -> Text -> GWidget sub master ()) + -> (Text -> Text -> [Text] -> Text -> Bool -> Text -> GWidget sub master ()) -> [(Text, a)] -> Field sub master [a] multiSelectFieldHelper outside inside opts = Field { fieldParse = return . selectParser @@ -429,7 +429,7 @@ selectFieldHelper :: (Eq a, RenderMessage master FormMessage) => (Text -> Text -> GWidget sub master () -> GWidget sub master ()) -> (Text -> Text -> Bool -> GWidget sub master ()) - -> (Text -> Text -> Text -> Text -> Bool -> Text -> GWidget sub master ()) + -> (Text -> Text -> [Text] -> Text -> Bool -> Text -> GWidget sub master ()) -> GHandlerT sub master IO (OptionList a) -> Field sub master a selectFieldHelper outside onOpt inside opts' = Field { fieldParse = \x -> do @@ -482,7 +482,7 @@ fileAFormReq fs = AForm $ \(master, langs) menvs ints -> do , fvTooltip = fmap (toHtml . renderMessage master langs) $ fsTooltip fs , fvId = id' , fvInput = [WHAMLET| - + |] , fvErrors = errs , fvRequired = True @@ -511,7 +511,7 @@ fileAFormOpt fs = AForm $ \(master, langs) menvs ints -> do , fvTooltip = fmap (toHtml . renderMessage master langs) $ fsTooltip fs , fvId = id' , fvInput = [WHAMLET| - + |] , fvErrors = errs , fvRequired = False diff --git a/yesod-form/Yesod/Form/Jquery.hs b/yesod-form/Yesod/Form/Jquery.hs index dbb40463..710088c7 100644 --- a/yesod-form/Yesod/Form/Jquery.hs +++ b/yesod-form/Yesod/Form/Jquery.hs @@ -20,7 +20,7 @@ import Yesod.Form import Yesod.Widget import Data.Time (UTCTime (..), Day, TimeOfDay (..), timeOfDayToTime, timeToTimeOfDay) -import qualified Data.Text as T (null) +import qualified Data.Text as T import Data.Char (isSpace) import Data.Default import Text.Hamlet (shamlet) @@ -81,7 +81,7 @@ jqueryDayField jds = Field . unpack , fieldView = \theId name theClass val isReq -> do addHtml [HTML|\ - + |] addScript' urlJqueryJs addScript' urlJqueryUiJs @@ -132,7 +132,7 @@ jqueryDayTimeField = Field { fieldParse = blank $ parseUTCTime . unpack , fieldView = \theId name theClass val isReq -> do addHtml [HTML|\ - + |] addScript' urlJqueryJs addScript' urlJqueryUiJs @@ -162,7 +162,7 @@ jqueryAutocompleteField src = Field { fieldParse = blank $ Right , fieldView = \theId name theClass val isReq -> do addHtml [HTML|\ - + |] addScript' urlJqueryJs addScript' urlJqueryUiJs diff --git a/yesod-form/Yesod/Form/MassInput.hs b/yesod-form/Yesod/Form/MassInput.hs index 812d3bd3..7cb80bc0 100644 --- a/yesod-form/Yesod/Form/MassInput.hs +++ b/yesod-form/Yesod/Form/MassInput.hs @@ -111,7 +111,7 @@ withDelete af = do , fsTooltip = Nothing , fsName = Just deleteName , fsId = Nothing - , fsClass = "" + , fsClass = [] } $ Just False (res, xml) <- aFormToForm af return $ Right (res, xml $ xml2 []) diff --git a/yesod-form/Yesod/Form/Nic.hs b/yesod-form/Yesod/Form/Nic.hs index 4cabd3f8..582ca451 100644 --- a/yesod-form/Yesod/Form/Nic.hs +++ b/yesod-form/Yesod/Form/Nic.hs @@ -20,7 +20,7 @@ import Text.Blaze.Renderer.String (renderHtml) import Text.Blaze (preEscapedText) import Control.Monad.Trans.Class (lift) import Data.Text (Text, pack) -import qualified Data.Text as T (null) +import qualified Data.Text as T import Data.Maybe (listToMaybe) class YesodNic a where @@ -38,7 +38,7 @@ nicHtmlField = Field #else [$shamlet| #endif - #{showVal val} + #{showVal val} |] addScript' urlNicEdit addJulius diff --git a/yesod-form/Yesod/Form/Types.hs b/yesod-form/Yesod/Form/Types.hs index a3c0ae30..cdbed510 100644 --- a/yesod-form/Yesod/Form/Types.hs +++ b/yesod-form/Yesod/Form/Types.hs @@ -102,11 +102,11 @@ data FieldSettings msg = FieldSettings , fsTooltip :: Maybe msg , fsId :: Maybe Text , fsName :: Maybe Text - , fsClass :: Text + , fsClass :: [Text] } instance (a ~ Text) => IsString (FieldSettings a) where - fromString s = FieldSettings (fromString s) Nothing Nothing Nothing "" + fromString s = FieldSettings (fromString s) Nothing Nothing Nothing [] data FieldView sub master = FieldView { fvLabel :: Html @@ -122,7 +122,7 @@ data Field sub master a = Field -- | ID, name, class, (invalid text OR legimiate result), required? , fieldView :: Text -> Text - -> Text + -> [Text] -> Either Text a -> Bool -> GWidget sub master ()