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

Safe HaskellNone
LanguageHaskell98

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 -> Input Source

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 

data Label Source

A block label, inline label, or implied value label

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 a Source

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_tag Source

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 -> Collection Source

Derive a collection from an enumerable type

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

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 -> Text Source

Format identifiers nicely for humans to read

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

applyAttrs Source

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