[web-devel] help with fileField

Knut Olav Bøhmer bohmer at gmail.com
Sun Jan 2 23:14:03 CET 2011


Hi,

Can anyone help me extend the "Random bananas" example from
http://docs.yesodweb.com/book/forms/ to include a fileField, so that I
can understand how to use the fileField.

I have tried something like this:

data Params = Params
    { minNumber :: Int
    , maxNumber :: Int
    , singleWord :: String
    , pluralWord :: String
    , fileTest :: FileInfo
    }


paramsFormlet :: Maybe Params -> Form s m Params
-- Same as: paramsFormlet :: Formlet s m Params
paramsFormlet mparams = fieldsToTable $ Params
    <$> intField "Minimum number" (fmap minNumber mparams)
    <*> intField "Maximum number" (fmap maxNumber mparams)
    <*> stringField "Single word" (fmap singleWord mparams)
    <*> stringField "Plural word" (fmap pluralWord mparams)
    <*> fileField  "test" (fmap fileTest mparams)


I have problems understanding what's going on here.


Regards
-- 
Knut Olav Bøhmer



More information about the web-devel mailing list