
Sorry, accidently replied off-list last time. Anyway, code looks good,
and I've pulled it into the ver0.6 branch.
Thanks!
Michael
On Fri, Oct 15, 2010 at 1:56 AM, Matt Brown
Adding fiRequired worked for me, and was quite painless: http://github.com/softmechanics/yesod/commit/77eb435a629717f063f7a3119016234...
Now my fieldToDivs is:
fieldsToDivs :: FormField sub y a -> Form sub y a fieldsToDivs = mapFormXml $ mapM_ go where go fi = do let cls = string $ if fiRequired fi then "fm-req" else "fm-opt" wrapWidget (fiInput fi) $ \w -> [$hamlet| %div!class=$cls$ %label!for=$fiIdent.fi$ $fiLabel.fi$ .tooltip $fiTooltip.fi$ ^w^ $maybe fiErrors.fi err %div.errors $err$ |]
-matt
On Thu, Oct 14, 2010 at 1:46 PM, Matt Brown
wrote: Hello all,
I'm new to Yesod, and I'm trying to render my forms like this: http://www.stylephreak.com/uploads/source/cssforms/cssform.php.
This has two main requirements: Use divs instead of tables, and specify whether the field is required or optional. This is what I have so far:
fieldsToDivs :: FormField sub y a -> Form sub y a fieldsToDivs = mapFormXml $ mapM_ go where go fi = do let cls = string $ if fieldRequired fi then "fm-req" else "fm-opt" wrapWidget (fiInput fi) $ \w -> [$hamlet| %div!class=$cls$ %label!for=$fiIdent.fi$ $fiLabel.fi$ .tooltip $fiTooltip.fi$ ^w^ $maybe fiErrors.fi err %div.errors $err$ |]
fieldRequired _ = True
I'm not sure how to implement fieldRequired. Is there a way to infer required/optional from FieldInfo? Would it make sense to add fiRequired :: Bool to FieldInfo?
thanks, -matt
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel