Safe Haskell | None |
---|
This module provides functions creating Reform using HSP 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.HSP.String.
- inputText :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text Text)) => Text -> Form m input error [XMLGenT x (XMLType x)] () Text
- inputPassword :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text Text)) => Form m input error [XMLGenT x (XMLType x)] () Text
- inputSubmit :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text Text)) => Text -> Form m input error [XMLGenT x (XMLType x)] () (Maybe Text)
- inputReset :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text Text)) => Text -> Form m input error [XMLGenT x (XMLType x)] () ()
- inputHidden :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text Text)) => Text -> Form m input error [XMLGenT x (XMLType x)] () Text
- inputButton :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text Text)) => Text -> Form m input error [XMLGenT x (XMLType x)] () ()
- inputCheckbox :: forall x error input m. (Monad m, FormInput input, FormError error, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId)) => Bool -> Form m input error [XMLGenT x (XMLType x)] () Bool
- inputCheckboxes :: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, XMLGenerator x, StringType x ~ Text, EmbedAsChild x lbl, EmbedAsAttr x (Attr Text FormId)) => [(a, lbl)] -> (a -> Bool) -> Form m input error [XMLGenT x (XMLType x)] () [a]
- inputRadio :: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, XMLGenerator x, StringType x ~ Text, EmbedAsChild x lbl, EmbedAsAttr x (Attr Text FormId)) => [(a, lbl)] -> (a -> Bool) -> Form m input error [XMLGenT x (XMLType x)] () a
- inputRadioForms :: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, XMLGenerator x, StringType x ~ Text, EmbedAsChild x lbl, EmbedAsAttr x (Attr Text FormId)) => [(Form m input error [XMLGenT x (XMLType x)] proof a, lbl)] -> a -> Form m input error [XMLGenT x (XMLType x)] proof a
- inputFile :: (Monad m, FormError error, FormInput input, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId)) => Form m input error [XMLGenT x (XMLType x)] () (FileType input)
- textarea :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text Text), EmbedAsChild x Text) => Int -> Int -> Text -> Form m input error [XMLGenT x (XMLType x)] () Text
- buttonSubmit :: (Monad m, FormError error, FormInput input, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsChild x children, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text Text)) => Text -> children -> Form m input error [XMLGenT x (XMLType x)] () (Maybe Text)
- buttonReset :: (Monad m, FormError error, XMLGenerator x, StringType x ~ Text, EmbedAsChild x children, EmbedAsAttr x (Attr Text FormId)) => children -> Form m input error [XMLGenT x (XMLType x)] () ()
- button :: (Monad m, FormError error, FormInput input, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsChild x children, EmbedAsAttr x (Attr Text FormId)) => children -> Form m input error [XMLGenT x (XMLType x)] () ()
- select :: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, XMLGenerator x, StringType x ~ Text, EmbedAsChild x lbl, EmbedAsAttr x (Attr Text FormId)) => [(a, lbl)] -> (a -> Bool) -> Form m input error [XMLGenT x (XMLType x)] () a
- selectMultiple :: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, XMLGenerator x, StringType x ~ Text, EmbedAsChild x lbl, EmbedAsAttr x (Attr Text FormId)) => [(a, lbl)] -> (a -> Bool) -> Form m input error [XMLGenT x (XMLType x)] () [a]
- label :: (Monad m, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsChild x c) => c -> Form m input error [XMLGenT x (XMLType x)] () ()
- labelText :: (Monad m, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsChild x Text) => Text -> Form m input error [XMLGenT x (XMLType x)] () ()
- errorList :: (Monad m, XMLGenerator x, StringType x ~ Text, EmbedAsChild x error) => Form m input error [XMLGenT x (XMLType x)] () ()
- childErrorList :: (Monad m, XMLGenerator x, StringType x ~ Text, EmbedAsChild x error) => Form m input error [XMLGenT x (XMLType x)] () ()
- br :: (Monad m, XMLGenerator x, StringType x ~ Text) => Form m input error [XMLGenT x (XMLType x)] () ()
- fieldset :: (Monad m, Functor m, XMLGenerator x, StringType x ~ Text, EmbedAsChild x c) => Form m input error c proof a -> Form m input error [XMLGenT x (XMLType x)] proof a
- ol :: (Monad m, Functor m, XMLGenerator x, StringType x ~ Text, EmbedAsChild x c) => Form m input error c proof a -> Form m input error [XMLGenT x (XMLType x)] proof a
- ul :: (Monad m, Functor m, XMLGenerator x, StringType x ~ Text, EmbedAsChild x c) => Form m input error c proof a -> Form m input error [XMLGenT x (XMLType x)] proof a
- li :: (Monad m, Functor m, XMLGenerator x, StringType x ~ Text, EmbedAsChild x c) => Form m input error c proof a -> Form m input error [XMLGenT x (XMLType x)] proof a
- form :: (XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text action)) => action -> [(Text, Text)] -> [XMLGenT x (XMLType x)] -> [XMLGenT x (XMLType x)]
- setAttrs :: (EmbedAsAttr x attr, XMLGenerator x, StringType x ~ Text, Monad m, Functor m) => Form m input error [XMLGenT x (XMLType x)] proof a -> attr -> Form m input error [GenXML x] proof a
<input> element
:: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text Text)) | |
=> Text | initial value |
-> Form m input error [XMLGenT x (XMLType x)] () Text |
Create an <input type="text">
element
inputPassword :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text Text)) => Form m input error [XMLGenT x (XMLType x)] () TextSource
Create an <input type="password">
element
:: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text Text)) | |
=> Text |
|
-> Form m input error [XMLGenT x (XMLType x)] () (Maybe Text) |
Create an <input type="submit">
element
returns:
Just
value- if this button was used to submit the form.
Nothing
- if this button was not used to submit the form.
:: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text Text)) | |
=> Text | value attribute. Used only to label the button. |
-> Form m input error [XMLGenT x (XMLType x)] () () |
Create an <input type="reset">
element
This element does not add any data to the form data set.
:: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text Text)) | |
=> Text | value to store in the hidden element |
-> Form m input error [XMLGenT x (XMLType x)] () Text |
Create an <input type="hidden">
element
:: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text Text)) | |
=> Text | value attribute. Used to label the button. |
-> Form m input error [XMLGenT x (XMLType x)] () () |
Create an <input type="button">
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: button
:: forall x error input m . (Monad m, FormInput input, FormError error, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId)) | |
=> Bool | initially checked |
-> Form m input error [XMLGenT x (XMLType x)] () Bool |
Create a single <input type="checkbox">
element
returns a Bool
indicating if it was checked or not.
see also inputCheckboxes
:: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, XMLGenerator x, StringType x ~ Text, EmbedAsChild x lbl, EmbedAsAttr x (Attr Text FormId)) | |
=> [(a, lbl)] | (value, label) |
-> (a -> Bool) | function which marks if a value should be checked (aka, selected) initially or not. Can match zero or more elements. |
-> Form m input error [XMLGenT x (XMLType x)] () [a] |
Create a group of <input type="checkbox">
elements
:: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, XMLGenerator x, StringType x ~ Text, EmbedAsChild x lbl, EmbedAsAttr x (Attr Text FormId)) | |
=> [(a, lbl)] | (value, label) |
-> (a -> Bool) | predicate which returns |
-> Form m input error [XMLGenT x (XMLType x)] () a |
Create a group of <input type="radio">
elements
:: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, XMLGenerator x, StringType x ~ Text, EmbedAsChild x lbl, EmbedAsAttr x (Attr Text FormId)) | |
=> [(Form m input error [XMLGenT x (XMLType x)] proof a, lbl)] | value, label, initially checked |
-> a | default |
-> Form m input error [XMLGenT x (XMLType x)] proof a |
Create a group of radio buttons that select between sub-forms
inputFile :: (Monad m, FormError error, FormInput input, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId)) => Form m input error [XMLGenT x (XMLType x)] () (FileType input)Source
Create an <input type="file">
element
This control may succeed even if the user does not actually select a file to upload. In that case the uploaded name will likely be "" and the file contents will be empty as well.
<textarea> element
:: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text Text), EmbedAsChild x Text) | |
=> Int | cols |
-> Int | rows |
-> Text | initial contents |
-> Form m input error [XMLGenT x (XMLType x)] () Text |
Create a <textarea></textarea> element
<button> element
:: (Monad m, FormError error, FormInput input, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsChild x children, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text Text)) | |
=> Text | value attribute. Returned if this button submits the form. |
-> children | children to embed in the <button> |
-> Form m input error [XMLGenT x (XMLType x)] () (Maybe Text) |
create a <button type="submit"></button>
element
:: (Monad m, FormError error, XMLGenerator x, StringType x ~ Text, EmbedAsChild x children, EmbedAsAttr x (Attr Text FormId)) | |
=> children | children of the |
-> Form m input error [XMLGenT x (XMLType x)] () () |
create a <button type="reset"></button>
element
This element does not add any data to the form data set.
:: (Monad m, FormError error, FormInput input, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsChild x children, EmbedAsAttr x (Attr Text FormId)) | |
=> children | children to embed in the <button> |
-> Form m input error [XMLGenT x (XMLType x)] () () |
create a <button type="button"></button>
element
This element does not add any data to the form data set.
<select> element
:: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, XMLGenerator x, StringType x ~ Text, EmbedAsChild x lbl, EmbedAsAttr x (Attr Text FormId)) | |
=> [(a, lbl)] | (value, label) |
-> (a -> Bool) | specifies which value is initially selected. Must match *exactly one* element in the list of choices |
-> Form m input error [XMLGenT x (XMLType x)] () a |
create <select></select>
element plus its <option></option>
children.
see also: selectMultiple
:: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, XMLGenerator x, StringType x ~ Text, EmbedAsChild x lbl, EmbedAsAttr x (Attr Text FormId)) | |
=> [(a, lbl)] | (value, label) |
-> (a -> Bool) | specifies which values are initially selected. Can match 0 or more elements. |
-> Form m input error [XMLGenT x (XMLType x)] () [a] |
create <select multiple="multiple"></select>
element plus its <option></option>
children.
This creates a <select>
element which allows more than one item to be selected.
<label> element
label :: (Monad m, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsChild x c) => c -> Form m input error [XMLGenT x (XMLType x)] () ()Source
labelText :: (Monad m, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsChild x Text) => Text -> Form m input error [XMLGenT x (XMLType x)] () ()Source
create a <label>
element.
Use this with or ++ to ensure that the for
attribute references the correct id
.
labelText "some input field: " ++> inputText ""
This function is provided as an alternative to label
because when
the OverloadedStrings
extension is enabled, you will get
ambiguous type errors when attempting to apply label
to a string
literal. While the type error can be fixed using an explicit type
signature, calling labelText
looks nicer.
errors
errorList :: (Monad m, XMLGenerator x, StringType x ~ Text, EmbedAsChild x error) => Form m input error [XMLGenT x (XMLType x)] () ()Source
childErrorList :: (Monad m, XMLGenerator x, StringType x ~ Text, EmbedAsChild x error) => Form m input error [XMLGenT x (XMLType x)] () ()Source
layout functions
br :: (Monad m, XMLGenerator x, StringType x ~ Text) => Form m input error [XMLGenT x (XMLType x)] () ()Source
create a <br>
tag.
fieldset :: (Monad m, Functor m, XMLGenerator x, StringType x ~ Text, EmbedAsChild x c) => Form m input error c proof a -> Form m input error [XMLGenT x (XMLType x)] proof aSource
wrap a <fieldset class="reform">
around a Form
ol :: (Monad m, Functor m, XMLGenerator x, StringType x ~ Text, EmbedAsChild x c) => Form m input error c proof a -> Form m input error [XMLGenT x (XMLType x)] proof aSource
wrap an <ol class="reform">
around a Form
ul :: (Monad m, Functor m, XMLGenerator x, StringType x ~ Text, EmbedAsChild x c) => Form m input error c proof a -> Form m input error [XMLGenT x (XMLType x)] proof aSource
wrap a <ul class="reform">
around a Form
li :: (Monad m, Functor m, XMLGenerator x, StringType x ~ Text, EmbedAsChild x c) => Form m input error c proof a -> Form m input error [XMLGenT x (XMLType x)] proof aSource
wrap a <li class="reform">
around a Form
:: (XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text action)) | |
=> action | action url |
-> [(Text, Text)] | extra hidden fields to add to form |
-> [XMLGenT x (XMLType x)] | children |
-> [XMLGenT x (XMLType x)] |
create <form action=action method="POST" enctype="multipart/form-data">
setAttrs :: (EmbedAsAttr x attr, XMLGenerator x, StringType x ~ Text, Monad m, Functor m) => Form m input error [XMLGenT x (XMLType x)] proof a -> attr -> Form m input error [GenXML x] proof aSource
set the attributes on the top-level elements of Form