Safe Haskell | None |
---|
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 {
- 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
- = Label Text
- | InlineLabel Text
- | DefaultLabel
- 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 -> InputSource
The type of a widget renderer
class DefaultWidget a whereSource
Infer a Widget
based on type
DefaultWidget Bool | |
DefaultWidget Char | |
DefaultWidget Double | |
DefaultWidget Float | |
DefaultWidget Int | |
DefaultWidget Integer | |
DefaultWidget Text | |
DefaultWidget EmailAddress | |
DefaultWidget LocalTime | |
DefaultWidget ZonedTime | |
DefaultWidget TimeOfDay | |
DefaultWidget UTCTime | |
DefaultWidget Day | |
DefaultWidget URI | |
DefaultWidget a => DefaultWidget [a] | |
(Integral a, Show a) => DefaultWidget (Ratio a) | |
DefaultWidget a => DefaultWidget (Maybe 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
data InputOptions Source
The setup for rendering an input. Blank is mempty
InputOptions | |
|
A block label, inline label, or implied value label
Label Text | |
InlineLabel Text | |
DefaultLabel |
Wrappers
unShowRead :: ShowRead a -> aSource
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 -> aSource
Widgets
Text-like
Numbers
Dates and times
date :: FormatTime a => Widget aSource
time :: FormatTime a => Widget aSource
datetime :: FormatTime a => Widget aSource
datetime_local :: FormatTime a => Widget aSource
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 TextSource
multi_select :: GroupedCollection -> Widget [Text]Source
radio_buttons :: GroupedCollection -> Widget TextSource
buttons :: GroupedCollection -> Widget TextSource
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 -> 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
group_ :: Collection -> GroupedCollectionSource
Push any Collection
to a trivial GroupedCollection