{-# LANGUAGE RankNTypes, TypeFamilies #-} {- | This module provides functions creating Reform using Hamlet markup. This module assumes that you wish for text based controls such as 'inputText' and 'textarea' to using 'Text' values. If you prefer 'String' see "Text.Reform.Hamlet.String". -} module Text.Reform.Hamlet.Text ( -- * \ element inputText , inputPassword , inputSubmit , inputReset , inputHidden , inputButton , inputCheckbox , inputCheckboxes , inputRadio , inputFile -- * \ element , textarea -- * \ element , buttonSubmit , buttonReset , button -- * \ element , select , selectMultiple -- * \ element , label , labelText -- * errors , errorList , childErrorList -- * layout functions , br , fieldset , ol , ul , li , form ) where import Data.Text (empty) import qualified Data.Text as T import Data.Text.Lazy (Text) import Text.Blaze (ToMarkup(..)) import Text.Reform import qualified Text.Reform.Hamlet.Common as C import Text.Hamlet (HtmlUrl) -- | Create an @\@ element inputText :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) => T.Text -- ^ initial value -> Form m input error (HtmlUrl url) () T.Text inputText initialValue = C.inputText getInputText initialValue -- | Create an @\@ element inputPassword :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) => Form m input error (HtmlUrl url) () T.Text inputPassword = C.inputPassword getInputText empty -- | Create an @\@ element -- -- returns: -- -- [@Just@ /value/] if this button was used to submit the form. -- -- [@Nothing@] if this button was not used to submit the form. inputSubmit :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) => T.Text -- ^ @value@ attribute. Used for button label, and value if button is submitted. -> Form m input error (HtmlUrl url) () (Maybe T.Text) inputSubmit initialValue = C.inputSubmit getInputText initialValue -- | Create an @\@ element -- -- This element does not add any data to the form data set. inputReset :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) => T.Text -- ^ value attribute. Used only to label the button. -> Form m input error (HtmlUrl url) () () inputReset = C.inputReset -- | Create an @\@ element inputHidden :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) => T.Text -- ^ value to store in the hidden element -> Form m input error (HtmlUrl url) () T.Text inputHidden initialValue = C.inputHidden getInputText initialValue -- | Create an @\@ element -- -- The element is a push button with a text label. The button does nothing by default, but actions can be added using javascript. This element does not add any data to the form data set. -- -- see also: 'C.button' inputButton :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) => Text -- ^ value attribute. Used to label the button. -> Form m input error (HtmlUrl url) () () inputButton label = C.inputButton label -- | Create a \\<\/textarea\> element textarea :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) => Int -- ^ cols -> Int -- ^ rows -> T.Text -- ^ initial contents -> Form m input error (HtmlUrl url) () T.Text textarea rows cols initialValue = C.textarea getInputText rows cols initialValue -- | create a @\