Tutorial produces bad HTML #45

Closed
dubiousdavid opened this Issue Aug 14, 2012 · 2 comments

Comments

Projects
None yet
2 participants

The form element is not embedded within the body element. The rendered output is:

<form method="POST" enctype="application/x-www-form-urlencoded" action="/"><!DOCTYPE HTML>
<html><head><title>digestive-functors tutorial</title><style type="text/css">label {width: 130px; float: left; clear: both}ul.digestive-functors-error-list { color: red; list-style-type: none; padding-left: 0px;}</style></head><body><style type="text/css">label {width: 130px; float: left; clear: both}ul.digestive-functors-error-list { color: red; list-style-type: none; padding-left: 0px;}</style><h2>Author</h2><label for="test.author.name">Name: </label><input type="text" id="test.author.name" name="test.author.name" value=""><br><label for="test.author.mail">Email address: </label><input type="text" id="test.author.mail" name="test.author.mail" value=""><br><h2>Package</h2><label for="test.package.name">Name: </label><input type="text" id="test.package.name" name="test.package.name" value=""><br><label for="test.package.version">Version: </label><input type="text" id="test.package.version" name="test.package.version" value="0.0.0.1"><br><label for="test.package.category">Category: </label><select id="test.package.category" name="test.package.category"><option value="test.package.category.0" selected="selected">Web</option><option value="test.package.category.1">Text</option><option value="test.package.category.2">Math</option></select><br><br><input type="submit" value="Submit"></body></html></form>

The following fixes the issue and removes the duplicate css inclusion.

site :: Happstack.ServerPart Happstack.Response
site = do
    Happstack.decodeBody $ Happstack.defaultBodyPolicy "/tmp" 4096 4096 4096
    r <- runForm "test" releaseForm
    case r of
        (view, Nothing) -> do
            let view' = fmap H.toHtml view
            Happstack.ok $ Happstack.toResponse  $
                template $ do
                    form view' "/" $ do
                        releaseView view'
                        H.br
                        inputSubmit "Submit"
        (_, Just release) -> Happstack.ok $ Happstack.toResponse $
            template $ do
                css
                H.h1 "Release received"
                H.p $ H.toHtml $ show release

jaspervdj closed this in 11529fc Aug 15, 2012

Owner

jaspervdj commented Aug 15, 2012

Thanks for the patch! Feel free to file a pull request next time, so you get proper credit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment