parent
d7832b0535
commit
b13c08f001
@ -9,7 +9,7 @@ module Yesod.Form.Class
|
|||||||
import Text.Hamlet
|
import Text.Hamlet
|
||||||
import Yesod.Form.Fields
|
import Yesod.Form.Fields
|
||||||
import Yesod.Form.Core
|
import Yesod.Form.Core
|
||||||
import Yesod.Form.Profiles (Textarea, EscapedHtml)
|
import Yesod.Form.Profiles (Textarea)
|
||||||
import Data.Int (Int64)
|
import Data.Int (Int64)
|
||||||
import Data.Time (Day, TimeOfDay)
|
import Data.Time (Day, TimeOfDay)
|
||||||
|
|
||||||
@ -59,8 +59,3 @@ instance ToFormField Textarea y where
|
|||||||
toFormField = textareaField
|
toFormField = textareaField
|
||||||
instance ToFormField (Maybe Textarea) y where
|
instance ToFormField (Maybe Textarea) y where
|
||||||
toFormField = maybeTextareaField
|
toFormField = maybeTextareaField
|
||||||
|
|
||||||
instance ToFormField EscapedHtml y where
|
|
||||||
toFormField = escapedHtmlField
|
|
||||||
instance ToFormField (Maybe EscapedHtml) y where
|
|
||||||
toFormField = maybeEscapedHtmlField
|
|
||||||
|
|||||||
@ -4,7 +4,6 @@ module Yesod.Form.Fields
|
|||||||
-- ** Required
|
-- ** Required
|
||||||
stringField
|
stringField
|
||||||
, textareaField
|
, textareaField
|
||||||
, escapedHtmlField
|
|
||||||
, hiddenField
|
, hiddenField
|
||||||
, intField
|
, intField
|
||||||
, doubleField
|
, doubleField
|
||||||
@ -18,7 +17,6 @@ module Yesod.Form.Fields
|
|||||||
-- ** Optional
|
-- ** Optional
|
||||||
, maybeStringField
|
, maybeStringField
|
||||||
, maybeTextareaField
|
, maybeTextareaField
|
||||||
, maybeEscapedHtmlField
|
|
||||||
, maybeHiddenField
|
, maybeHiddenField
|
||||||
, maybeIntField
|
, maybeIntField
|
||||||
, maybeDoubleField
|
, maybeDoubleField
|
||||||
@ -269,12 +267,6 @@ textareaField = requiredFieldHelper textareaFieldProfile
|
|||||||
maybeTextareaField :: FormFieldSettings -> FormletField sub y (Maybe Textarea)
|
maybeTextareaField :: FormFieldSettings -> FormletField sub y (Maybe Textarea)
|
||||||
maybeTextareaField = optionalFieldHelper textareaFieldProfile
|
maybeTextareaField = optionalFieldHelper textareaFieldProfile
|
||||||
|
|
||||||
escapedHtmlField :: FormFieldSettings -> FormletField sub y EscapedHtml
|
|
||||||
escapedHtmlField = requiredFieldHelper escapedHtmlFieldProfile
|
|
||||||
|
|
||||||
maybeEscapedHtmlField :: FormFieldSettings -> FormletField sub y (Maybe EscapedHtml)
|
|
||||||
maybeEscapedHtmlField = optionalFieldHelper escapedHtmlFieldProfile
|
|
||||||
|
|
||||||
hiddenField :: FormFieldSettings -> FormletField sub y String
|
hiddenField :: FormFieldSettings -> FormletField sub y String
|
||||||
hiddenField = requiredFieldHelper hiddenFieldProfile
|
hiddenField = requiredFieldHelper hiddenFieldProfile
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
module Yesod.Form.Profiles
|
module Yesod.Form.Profiles
|
||||||
( stringFieldProfile
|
( stringFieldProfile
|
||||||
, textareaFieldProfile
|
, textareaFieldProfile
|
||||||
, escapedHtmlFieldProfile
|
|
||||||
, hiddenFieldProfile
|
, hiddenFieldProfile
|
||||||
, intFieldProfile
|
, intFieldProfile
|
||||||
, dayFieldProfile
|
, dayFieldProfile
|
||||||
@ -17,7 +16,6 @@ module Yesod.Form.Profiles
|
|||||||
, parseDate
|
, parseDate
|
||||||
, parseTime
|
, parseTime
|
||||||
, Textarea (..)
|
, Textarea (..)
|
||||||
, EscapedHtml (..)
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Yesod.Form.Core
|
import Yesod.Form.Core
|
||||||
@ -112,23 +110,6 @@ textareaFieldProfile = FieldProfile
|
|||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
|
|
||||||
-- | A newtype wrapper around a 'Html' that automatically entity-escapes all
|
|
||||||
-- input from the user. This means that values stored in the database are
|
|
||||||
-- already entity-escaped, avoiding escaping each time it is rendered.
|
|
||||||
newtype EscapedHtml = EscapedHtml { unEscapedHtml :: Html }
|
|
||||||
deriving (Show, Eq, PersistField)
|
|
||||||
instance ToHtml EscapedHtml where
|
|
||||||
toHtml = unEscapedHtml
|
|
||||||
|
|
||||||
escapedHtmlFieldProfile :: FieldProfile sub y EscapedHtml
|
|
||||||
escapedHtmlFieldProfile = FieldProfile
|
|
||||||
{ fpParse = Right . EscapedHtml . string
|
|
||||||
, fpRender = U.toString . renderHtml . unEscapedHtml
|
|
||||||
, fpWidget = \theId name val _isReq -> addBody [$hamlet|
|
|
||||||
%textarea#$theId$!name=$name$ $val$
|
|
||||||
|]
|
|
||||||
}
|
|
||||||
|
|
||||||
hiddenFieldProfile :: FieldProfile sub y String
|
hiddenFieldProfile :: FieldProfile sub y String
|
||||||
hiddenFieldProfile = FieldProfile
|
hiddenFieldProfile = FieldProfile
|
||||||
{ fpParse = Right
|
{ fpParse = Right
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod
|
name: yesod
|
||||||
version: 0.5.1
|
version: 0.5.0.4
|
||||||
license: BSD3
|
license: BSD3
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman <michael@snoyman.com>
|
author: Michael Snoyman <michael@snoyman.com>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user