Some FIXMEs
This commit is contained in:
parent
7377919f6c
commit
0c611f58fd
@ -14,6 +14,7 @@ module Yesod.Form.Core
|
|||||||
, fieldsToInput
|
, fieldsToInput
|
||||||
, mapFormXml
|
, mapFormXml
|
||||||
, checkForm
|
, checkForm
|
||||||
|
, checkField
|
||||||
, askParams
|
, askParams
|
||||||
, askFiles
|
, askFiles
|
||||||
, liftForm
|
, liftForm
|
||||||
@ -241,7 +242,10 @@ type FormField sub y = GForm sub y [FieldInfo sub y]
|
|||||||
type FormletField sub y a = Maybe a -> FormField sub y a
|
type FormletField sub y a = Maybe a -> FormField sub y a
|
||||||
type FormInput sub y = GForm sub y [GWidget sub y ()]
|
type FormInput sub y = GForm sub y [GWidget sub y ()]
|
||||||
|
|
||||||
-- | FIXME Add some docs, especially about how failures from this function don't show up in the HTML.
|
-- | Add a validation check to a form.
|
||||||
|
--
|
||||||
|
-- Note that if there is a validation error, this message will /not/
|
||||||
|
-- automatically appear on the form; for that, you need to use 'checkField'.
|
||||||
checkForm :: (a -> FormResult b) -> GForm s m x a -> GForm s m x b
|
checkForm :: (a -> FormResult b) -> GForm s m x a -> GForm s m x b
|
||||||
checkForm f (GForm form) = GForm $ do
|
checkForm f (GForm form) = GForm $ do
|
||||||
(res, xml, enc) <- form
|
(res, xml, enc) <- form
|
||||||
@ -251,6 +255,10 @@ checkForm f (GForm form) = GForm $ do
|
|||||||
FormMissing -> FormMissing
|
FormMissing -> FormMissing
|
||||||
return (res', xml, enc)
|
return (res', xml, enc)
|
||||||
|
|
||||||
|
-- | Add a validation check to a 'FormField'.
|
||||||
|
--
|
||||||
|
-- Unlike 'checkForm', the validation error will appear in the generated HTML
|
||||||
|
-- of the form.
|
||||||
checkField :: (a -> Either String b) -> FormField s m a -> FormField s m b
|
checkField :: (a -> Either String b) -> FormField s m a -> FormField s m b
|
||||||
checkField f (GForm form) = GForm $ do
|
checkField f (GForm form) = GForm $ do
|
||||||
(res, xml, enc) <- form
|
(res, xml, enc) <- form
|
||||||
@ -260,6 +268,8 @@ checkField f (GForm form) = GForm $ do
|
|||||||
case f a of
|
case f a of
|
||||||
Left e -> (FormFailure [e], Just e)
|
Left e -> (FormFailure [e], Just e)
|
||||||
Right x -> (FormSuccess x, Nothing)
|
Right x -> (FormSuccess x, Nothing)
|
||||||
|
FormFailure e -> (FormFailure e, Nothing)
|
||||||
|
FormMissing -> (FormMissing, Nothing)
|
||||||
let xml' =
|
let xml' =
|
||||||
case merr of
|
case merr of
|
||||||
Nothing -> xml
|
Nothing -> xml
|
||||||
|
|||||||
@ -12,7 +12,6 @@ module Yesod.Form.Profiles
|
|||||||
, emailFieldProfile
|
, emailFieldProfile
|
||||||
, urlFieldProfile
|
, urlFieldProfile
|
||||||
, doubleFieldProfile
|
, doubleFieldProfile
|
||||||
, fileFieldProfile
|
|
||||||
, parseDate
|
, parseDate
|
||||||
, parseTime
|
, parseTime
|
||||||
, Textarea (..)
|
, Textarea (..)
|
||||||
@ -20,7 +19,6 @@ module Yesod.Form.Profiles
|
|||||||
|
|
||||||
import Yesod.Form.Core
|
import Yesod.Form.Core
|
||||||
import Yesod.Widget
|
import Yesod.Widget
|
||||||
import Yesod.Request
|
|
||||||
import Text.Hamlet
|
import Text.Hamlet
|
||||||
import Data.Time (Day, TimeOfDay(..))
|
import Data.Time (Day, TimeOfDay(..))
|
||||||
import qualified Data.ByteString.Lazy.UTF8 as U
|
import qualified Data.ByteString.Lazy.UTF8 as U
|
||||||
@ -55,9 +53,6 @@ doubleFieldProfile = FieldProfile
|
|||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
|
|
||||||
fileFieldProfile :: FieldProfile s m FileInfo
|
|
||||||
fileFieldProfile = undefined -- FIXME
|
|
||||||
|
|
||||||
dayFieldProfile :: FieldProfile sub y Day
|
dayFieldProfile :: FieldProfile sub y Day
|
||||||
dayFieldProfile = FieldProfile
|
dayFieldProfile = FieldProfile
|
||||||
{ fpParse = parseDate
|
{ fpParse = parseDate
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user