From 8e025c822633551dff5911c2f5dc13b795bf1815 Mon Sep 17 00:00:00 2001 From: Maximilian Tagher Date: Mon, 24 Nov 2014 23:25:39 -0500 Subject: [PATCH] Further improvements --- yesod-form/Yesod/Form/Fields.hs | 54 +++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/yesod-form/Yesod/Form/Fields.hs b/yesod-form/Yesod/Form/Fields.hs index 3b10a37b..da9a02ec 100644 --- a/yesod-form/Yesod/Form/Fields.hs +++ b/yesod-form/Yesod/Form/Fields.hs @@ -4,9 +4,11 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE CPP #-} --- | Functions for creating inputs --- +-- | Field functions allow you to easily create and validate forms, cleanly handling the uncertainty of parsing user input. +-- -- When possible, the field functions use a specific input type (e.g. "number"), allowing supporting browsers to validate the input before form submission. Browsers can also improve usability with this information; for example, mobile browsers might present a specialized keyboard for an input of type "email" or "number". +-- +-- See the Yesod book for a broader overview of forms in Yesod. module Yesod.Form.Fields ( -- * i18n FormMessage (..) @@ -137,7 +139,8 @@ $newline never where showVal = either id (pack . show) -- | Creates an input with @type="date"@, validating the input using the 'parseDate' function. --- Add the @time@ package and import the 'Data.Time.Calendar' module to use this function. +-- +-- Add the @time@ package and import the "Data.Time.Calendar" module to use this function. dayField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Day dayField = Field { fieldParse = parseHelper $ parseDate . unpack @@ -149,9 +152,9 @@ $newline never } where showVal = either id (pack . show) --- | MTODO: Parses time from a [H]H:MM[:SS] format, with an optional AM or PM (if not given, AM is assumed for compatibility with a 24 hour clock system). --- | Creates an input with MTODO: should this use input type="time" ? --- Add the @time@ package and import the 'Data.Time.LocalTime' module to use this function. +-- | Parses time from a [H]H:MM[:SS] format, with an optional AM or PM (if not given, AM is assumed for compatibility with a 24 hour clock system). MTODO: should this use input type="time" ? +-- +-- Add the @time@ package and import the "Data.Time.LocalTime" module to use this function. timeField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m TimeOfDay timeField = Field { fieldParse = parseHelper parseTime @@ -180,8 +183,9 @@ $newline never } where showVal = either id (pack . renderHtml) --- | A newtype wrapper around a 'Text' whose 'ToHtml' instance converts newlines to HTML @\
@ tags. --- (When text is entered into a