reform-blaze-0.2.0: Add support for using blaze-html with Reform

Safe Haskell | None

Text.Reform.Blaze.Text

Contents

- <input> element
- <textarea> element
- <button> element
- <select> element
- <label> element
- errors
- layout functions

Description

This module provides functions creating Reform using blaze-html 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.Blaze.String.

Synopsis

- inputText :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) => Text -> Form m input error Html () Text
- inputPassword :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) => Form m input error Html () Text
- inputSubmit :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) => Text -> Form m input error Html () (Maybe Text)
- inputReset :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) => Text -> Form m input error Html () ()
- inputHidden :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) => Text -> Form m input error Html () Text
- inputButton :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) => Text -> Form m input error Html () ()
- inputCheckbox :: forall x error input m. (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) => Bool -> Form m input error Html () Bool
- inputCheckboxes :: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, ToMarkup lbl) => [(a, lbl)] -> (a -> Bool) -> Form m input error Html () [a]
- inputRadio :: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, ToMarkup lbl) => [(a, lbl)] -> (a -> Bool) -> Form m input error Html () a
- inputFile :: (Monad m, FormError error, FormInput input, ErrorInputType error ~ input) => Form m input error Html () (FileType input)
- textarea :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) => Int -> Int -> Text -> Form m input error Html () Text
- buttonSubmit :: (Monad m, FormError error, FormInput input, ErrorInputType error ~ input, ToMarkup children) => Text -> children -> Form m input error Html () (Maybe Text)
- buttonReset :: (Monad m, FormError error, ToMarkup children) => children -> Form m input error Html () ()
- button :: (Monad m, FormError error, ToMarkup children) => children -> Form m input error Html () ()
- select :: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, ToMarkup lbl) => [(a, lbl)] -> (a -> Bool) -> Form m input error Html () a
- selectMultiple :: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, ToMarkup lbl) => [(a, lbl)] -> (a -> Bool) -> Form m input error Html () [a]
- label :: (Monad m, ToMarkup children) => children -> Form m input error Html () ()
- errorList :: (Monad m, ToMarkup error) => Form m input error Html () ()
- childErrorList :: (Monad m, ToMarkup error) => Form m input error Html () ()
- br :: Monad m => Form m input error Html () ()
- fieldset :: (Monad m, Functor m) => Form m input error Html proof a -> Form m input error Html proof a
- ol :: (Monad m, Functor m) => Form m input error Html proof a -> Form m input error Html proof a
- ul :: (Monad m, Functor m) => Form m input error Html proof a -> Form m input error Html proof a
- li :: (Monad m, Functor m) => Form m input error Html proof a -> Form m input error Html proof a
- form :: ToValue action => action -> [(Text, Text)] -> Html -> Html

# <input> element

inputText Source

Arguments

:: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) |
=> Text | initial value
-> Form m input error Html () Text |

Create an `<input type="text">` element

inputPassword :: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) => Form m input error Html () Text Source

Create an `<input type="password">` element

inputSubmit Source

Arguments

:: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) |
=> Text | `value` attribute. Used for button label, and value if button is submitted.
-> Form m input error Html () (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.

inputReset Source

Arguments

:: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) |
=> Text | value attribute. Used only to label the button.
-> Form m input error Html () () |

Create an `<input type="reset">` element

This element does not add any data to the form data set.

inputHidden Source

Arguments

:: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) |
=> Text | value to store in the hidden element
-> Form m input error Html () Text |

Create an `<input type="hidden">` element

inputButton Source

Arguments

:: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) |
=> Text | value attribute. Used to label the button.
-> Form m input error Html () () |

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`

inputCheckbox Source

Arguments

:: forall x error input m . (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) |
=> Bool | initially checked
-> Form m input error Html () Bool |

Create a single `<input type="checkbox">` element

returns a `Bool` indicating if it was checked or not.

see also `inputCheckboxes` FIXME: Should this built on something in Generalized?

inputCheckboxes Source

Arguments

:: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, ToMarkup lbl) |
=> [(a, lbl)] | value, label, initially checked
-> (a -> Bool) | function which indicates if a value should be checked initially
-> Form m input error Html () [a] |

Create a group of `<input type="checkbox">` elements

inputRadio Source

Arguments

:: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, ToMarkup lbl) |
=> [(a, lbl)] | value, label, initially checked
-> (a -> Bool) | isDefault
-> Form m input error Html () a |

Create a group of `<input type="radio">` elements

inputFile :: (Monad m, FormError error, FormInput input, ErrorInputType error ~ input) => Form m input error Html () (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

textarea Source

Arguments

:: (Monad m, FormInput input, FormError error, ErrorInputType error ~ input) |
=> Int | cols
-> Int | rows
-> Text | initial contents
-> Form m input error Html () Text |

Create a <textarea></textarea> element

# <button> element

buttonSubmit Source

Arguments

:: (Monad m, FormError error, FormInput input, ErrorInputType error ~ input, ToMarkup children) |
=> Text | value attribute. Returned if this button submits the form.
-> children | children to embed in the <button>
-> Form m input error Html () (Maybe Text) |

create a `<button type="submit"></button>` element

buttonReset :: (Monad m, FormError error, ToMarkup children) => children -> Form m input error Html () ()Source

create a `<button type="reset"></button>` element

This element does not add any data to the form data set.

button :: (Monad m, FormError error, ToMarkup children) => children -> Form m input error Html () ()Source

create a `<button type="button"></button>` element

This element does not add any data to the form data set.

# <select> element

select Source

Arguments

:: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, ToMarkup lbl) |
=> [(a, lbl)] | value, label
-> (a -> Bool) | isDefault, must match *exactly one* element in the list of choices
-> Form m input error Html () a |

create `<select></select>` element plus its `<option></option>` children.

see also: `selectMultiple`

selectMultiple Source

Arguments

:: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, ToMarkup lbl) |
=> [(a, lbl)] | value, label, initially checked
-> (a -> Bool) | isSelected initially
-> Form m input error Html () [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, ToMarkup children) => children -> Form m input error Html () ()Source

create a `<label>` element.

Use this with or ++ to ensure that the `for` attribute references the correct `id`.

     label "some input field: " ++> inputText ""

# errors

errorList :: (Monad m, ToMarkup error) => Form m input error Html () ()Source

create a `<ul>` which contains all the errors related to the `Form`.

The `\ul\` will have the attribute `class="reform-error-list"`.

childErrorList :: (Monad m, ToMarkup error) => Form m input error Html () ()Source

create a `<ul>` which contains all the errors related to the `Form`.

Includes errors from child forms.

The `\ul\` will have the attribute `class="reform-error-list"`.

# layout functions

br :: Monad m => Form m input error Html () ()Source

create a `<br>` tag.

fieldset :: (Monad m, Functor m) => Form m input error Html proof a -> Form m input error Html proof aSource

wrap a `<fieldset class="reform">` around a `Form`

ol :: (Monad m, Functor m) => Form m input error Html proof a -> Form m input error Html proof aSource

wrap an `<ol class="reform">` around a `Form`

ul :: (Monad m, Functor m) => Form m input error Html proof a -> Form m input error Html proof aSource

wrap a `<ul class="reform">` around a `Form`

li :: (Monad m, Functor m) => Form m input error Html proof a -> Form m input error Html proof aSource

wrap a `<li class="reform">` around a `Form`

form Source

Arguments

:: ToValue action |
=> action | action url
-> [(Text, Text)] | hidden fields to add to form
-> Html | children
-> Html |

create `<form action=action method="POST" enctype="multipart/form-data">`