Allow multiple files (#448)
This commit is contained in:
parent
5b02ec8079
commit
363e4afeee
@ -539,10 +539,10 @@ fileAFormReq fs = AForm $ \(master, langs) menvs ints -> do
|
|||||||
Nothing -> (FormMissing, Nothing)
|
Nothing -> (FormMissing, Nothing)
|
||||||
Just (_, fenv) ->
|
Just (_, fenv) ->
|
||||||
case Map.lookup name fenv of
|
case Map.lookup name fenv of
|
||||||
Nothing ->
|
Just (fi:_) -> (FormSuccess fi, Nothing)
|
||||||
|
_ ->
|
||||||
let t = renderMessage master langs MsgValueRequired
|
let t = renderMessage master langs MsgValueRequired
|
||||||
in (FormFailure [t], Just $ toHtml t)
|
in (FormFailure [t], Just $ toHtml t)
|
||||||
Just fi -> (FormSuccess fi, Nothing)
|
|
||||||
let fv = FieldView
|
let fv = FieldView
|
||||||
{ fvLabel = toHtml $ renderMessage master langs $ fsLabel fs
|
{ fvLabel = toHtml $ renderMessage master langs $ fsLabel fs
|
||||||
, fvTooltip = fmap (toHtml . renderMessage master langs) $ fsTooltip fs
|
, fvTooltip = fmap (toHtml . renderMessage master langs) $ fsTooltip fs
|
||||||
@ -570,8 +570,8 @@ fileAFormOpt fs = AForm $ \(master, langs) menvs ints -> do
|
|||||||
Nothing -> (FormMissing, Nothing)
|
Nothing -> (FormMissing, Nothing)
|
||||||
Just (_, fenv) ->
|
Just (_, fenv) ->
|
||||||
case Map.lookup name fenv of
|
case Map.lookup name fenv of
|
||||||
Nothing -> (FormSuccess Nothing, Nothing)
|
Just (fi:_) -> (FormSuccess $ Just fi, Nothing)
|
||||||
Just fi -> (FormSuccess $ Just fi, Nothing)
|
_ -> (FormSuccess Nothing, Nothing)
|
||||||
let fv = FieldView
|
let fv = FieldView
|
||||||
{ fvLabel = toHtml $ renderMessage master langs $ fsLabel fs
|
{ fvLabel = toHtml $ renderMessage master langs $ fsLabel fs
|
||||||
, fvTooltip = fmap (toHtml . renderMessage master langs) $ fsTooltip fs
|
, fvTooltip = fmap (toHtml . renderMessage master langs) $ fsTooltip fs
|
||||||
|
|||||||
@ -224,7 +224,7 @@ postEnv = do
|
|||||||
else do
|
else do
|
||||||
(p, f) <- runRequestBody
|
(p, f) <- runRequestBody
|
||||||
let p' = Map.unionsWith (++) $ map (\(x, y) -> Map.singleton x [y]) p
|
let p' = Map.unionsWith (++) $ map (\(x, y) -> Map.singleton x [y]) p
|
||||||
return $ Just (p', Map.fromList f)
|
return $ Just (p', Map.unionsWith (++) $ map (\(k, v) -> Map.singleton k [v]) f)
|
||||||
|
|
||||||
runFormPostNoToken :: (Html -> MForm sub master (FormResult a, xml)) -> GHandler sub master ((FormResult a, xml), Enctype)
|
runFormPostNoToken :: (Html -> MForm sub master (FormResult a, xml)) -> GHandler sub master ((FormResult a, xml), Enctype)
|
||||||
runFormPostNoToken form = do
|
runFormPostNoToken form = do
|
||||||
|
|||||||
@ -76,7 +76,7 @@ instance Show Ints where
|
|||||||
show (IntCons i is) = show i ++ ('-' : show is)
|
show (IntCons i is) = show i ++ ('-' : show is)
|
||||||
|
|
||||||
type Env = Map.Map Text [Text]
|
type Env = Map.Map Text [Text]
|
||||||
type FileEnv = Map.Map Text FileInfo
|
type FileEnv = Map.Map Text [FileInfo]
|
||||||
|
|
||||||
type Lang = Text
|
type Lang = Text
|
||||||
type MForm sub master a = RWST (Maybe (Env, FileEnv), master, [Lang]) Enctype Ints (GHandler sub master) a
|
type MForm sub master a = RWST (Maybe (Env, FileEnv), master, [Lang]) Enctype Ints (GHandler sub master) a
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod-form
|
name: yesod-form
|
||||||
version: 1.1.3
|
version: 1.1.4
|
||||||
license: MIT
|
license: MIT
|
||||||
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