simple-form-0.2: Forms that configure themselves based on type

Safe HaskellNone

SimpleForm

Contents

Description

Forms that configure themselves based on type

This module is for constructing forms that only output to Html. For forms that also parse input, see SimpleForm.Combined

Synopsis

Documentation

type Widget a = Maybe a -> Maybe Text -> Text -> InputOptions -> InputSource

The type of a widget renderer

data Input Source

Representation of an input widget in HTML

Instances

Options

data InputOptions Source

The setup for rendering an input. Blank is mempty

Constructors

InputOptions 

Fields

label :: Maybe Label
 
hint :: Maybe Text
 
required :: Bool
 
disabled :: Bool
 
input_html :: [(Text, Text)]
 
label_html :: [(Text, Text)]
 
error_html :: [(Text, Text)]
 
hint_html :: [(Text, Text)]
 
wrapper_html :: [(Text, Text)]
 

data Label Source

A block label, inline label, or implied value label

Constructors

Label Text 
InlineLabel Text 
DefaultLabel 

Wrappers

newtype ShowRead a Source

Wrapper for types that should be rendered using show

Constructors

ShowRead a 

Instances

Eq a => Eq (ShowRead a) 
Ord a => Ord (ShowRead a) 
Read a => Read (ShowRead a) 
(Show a, Read a) => Show (ShowRead a) 
(Show a, Read a) => DefaultWidget (ShowRead a) 
Read a => DefaultValidation (ShowRead a) 

newtype SelectEnum a Source

Wrapper for select boxes on enumerable types

Constructors

SelectEnum a 

Instances

Bounded a => Bounded (SelectEnum a) 
Enum a => Enum (SelectEnum a) 
Eq a => Eq (SelectEnum a) 
Ord a => Ord (SelectEnum a) 
Read a => Read (SelectEnum a) 
(Show a, Read a) => Show (SelectEnum a) 
(Show a, Read a, Bounded a, Enum a) => DefaultWidget (SelectEnum a) 
(Show a, Read a, Bounded a, Enum a) => DefaultValidation (SelectEnum a) 

Widgets

Text-like

Numbers

number :: (Num a, Show a) => Widget aSource

Dates and times

Collections

type GroupedCollection = [(Text, [(Text, Text)])]Source

Collection of items for the user to choose from, with optional grouping

A trivial GroupedCollection (with just one, blankly-named group) should be treated by Widgets as if it were just a Collection

type Collection = [(Text, Text)]Source

Collection of items for the user to choose from

Helpers

input_tagSource

Arguments

:: Text

name

-> Maybe Text

textual value

-> Text

type

-> [[(Text, Text)]]

Extra default attributes

-> InputOptions

Attributes from options override defaults

-> Html 

<input />

selectEnum :: (Show a, Read a, Bounded a, Enum a) => a -> CollectionSource

Derive a collection from an enumerable type

enum :: (Show a, Read a, Bounded a, Enum a) => (GroupedCollection -> Widget Text) -> Widget aSource

Feed a collection Widget from an enumerable type

multiEnum :: (Show a, Read a, Bounded a, Enum a) => (GroupedCollection -> Widget [Text]) -> Widget [a]Source

Feed a multi-select collection Widget from an enumerable type

humanize :: Text -> TextSource

Format identifiers nicely for humans to read

maybeCons :: Bool -> a -> [a] -> [a]Source

applyAttrsSource

Arguments

:: [(Text, Text)]

Defaults

-> [(Text, Text)]

User overrides

-> Html

Apply attributes to this Html

-> Html 

Apply a list of default attributes and user overrides to some Html