Safe Haskell | None |
---|---|
Language | Haskell98 |
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
- type Widget a = Maybe a -> Maybe Text -> Text -> InputOptions -> Input
- class DefaultWidget a where
- data Input
- = Input Html
- | MultiInput [Html]
- | SelfLabelInput Html
- data InputOptions = InputOptions {}
- data Label
- newtype ShowRead a = ShowRead a
- unShowRead :: ShowRead a -> a
- newtype SelectEnum a = SelectEnum a
- unSelectEnum :: SelectEnum a -> a
- button :: Widget Text
- hidden :: Widget Text
- checkbox :: Widget Bool
- file :: Widget Text
- text :: Widget Text
- textarea :: Widget Text
- password :: Widget Text
- search :: Widget Text
- email :: Widget Text
- uri :: Widget Text
- tel :: Widget Text
- number :: (Num a, Show a) => Widget a
- integral :: (Integral a, Show a) => Widget a
- boundedNumber :: (Bounded a, Num a, Show a) => Widget a
- boundedIntegral :: (Bounded a, Integral a, Show a) => Widget a
- date :: FormatTime a => Widget a
- time :: FormatTime a => Widget a
- datetime :: FormatTime a => Widget a
- datetime_local :: FormatTime a => Widget a
- type GroupedCollection = [(Text, [(Text, Text)])]
- type Collection = [(Text, Text)]
- select :: GroupedCollection -> Widget Text
- multi_select :: GroupedCollection -> Widget [Text]
- radio_buttons :: GroupedCollection -> Widget Text
- buttons :: GroupedCollection -> Widget Text
- checkboxes :: GroupedCollection -> Widget [Text]
- input_tag :: Text -> Maybe Text -> Text -> [[(Text, Text)]] -> InputOptions -> Html
- selectEnum :: (Show a, Read a, Bounded a, Enum a) => a -> Collection
- enum :: (Show a, Read a, Bounded a, Enum a) => (GroupedCollection -> Widget Text) -> Widget a
- group_ :: Collection -> GroupedCollection
- multiEnum :: (Show a, Read a, Bounded a, Enum a) => (GroupedCollection -> Widget [Text]) -> Widget [a]
- humanize :: Text -> Text
- maybeCons :: Bool -> a -> [a] -> [a]
- applyAttrs :: [(Text, Text)] -> [(Text, Text)] -> Html -> Html
Documentation
type Widget a = Maybe a -> Maybe Text -> Text -> InputOptions -> Input Source
The type of a widget renderer
class DefaultWidget a where Source
Infer a Widget
based on type
DefaultWidget Bool | |
DefaultWidget Char | |
DefaultWidget Double | |
DefaultWidget Float | |
DefaultWidget Int | |
DefaultWidget Integer | |
DefaultWidget Text | |
DefaultWidget EmailAddress | |
DefaultWidget URI | |
DefaultWidget LocalTime | |
DefaultWidget ZonedTime | |
DefaultWidget TimeOfDay | |
DefaultWidget UTCTime | |
DefaultWidget Day | |
DefaultWidget a => DefaultWidget [a] | |
(Integral a, Show a) => DefaultWidget (Ratio a) | |
DefaultWidget a => DefaultWidget (Maybe a) | |
HasResolution a => DefaultWidget (Fixed a) | |
(Show a, Read a, Bounded a, Enum a) => DefaultWidget (SelectEnum a) | |
(Show a, Read a) => DefaultWidget (ShowRead a) | |
(DefaultWidget a, DefaultWidget b) => DefaultWidget (a, b) |
Representation of an input widget in HTML
Options
A block label, inline label, or implied value label
Wrappers
unShowRead :: ShowRead a -> a Source
newtype SelectEnum a Source
Wrapper for select boxes on enumerable types
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) |
unSelectEnum :: SelectEnum a -> a Source
Widgets
Text-like
Numbers
Dates and times
date :: FormatTime a => Widget a Source
time :: FormatTime a => Widget a Source
datetime :: FormatTime a => Widget a Source
datetime_local :: FormatTime a => Widget a Source
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 Widget
s as if it were just a Collection
type Collection = [(Text, Text)] Source
Collection of items for the user to choose from
select :: GroupedCollection -> Widget Text Source
multi_select :: GroupedCollection -> Widget [Text] Source
buttons :: GroupedCollection -> Widget Text Source
checkboxes :: GroupedCollection -> Widget [Text] Source
Helpers
:: 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
group_ :: Collection -> GroupedCollection Source
Push any Collection
to a trivial GroupedCollection