| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
FlexTask.InputTypes
Description
Premade data types for specific form needs.
Synopsis
- newtype MultipleChoice a = MultipleChoice {
- getChoices :: [a]
- newtype Hidden a = Hidden {
- getHidden :: a
- newtype SingleInputList a = SingleInputList {
- getList :: [a]
- data SingleChoiceSelection
- singleChoiceAnswer :: Int -> SingleChoiceSelection
- singleChoiceEmpty :: SingleChoiceSelection
- getAnswer :: SingleChoiceSelection -> Int
- getAnswerAsIndex :: SingleChoiceSelection -> Int
- type MultipleChoiceSelection = MultipleChoice SingleChoiceSelection
- multipleChoiceAnswer :: [Int] -> MultipleChoiceSelection
- multipleChoiceEmpty :: MultipleChoiceSelection
- getAnswers :: MultipleChoiceSelection -> [Int]
- getAnswersAsIndices :: MultipleChoiceSelection -> [Int]
Documentation
newtype MultipleChoice a Source #
Wrapper representing zero or more selected values in a multiple-choice field.
Constructors
| MultipleChoice | |
Fields
| |
Instances
Wrapper type for generating hidden fields. This can be used to transfer static information through the form to parsing. Note that the generated field still has a label. If the label is not left blank, then it will be displayed as normal.
The user can inspect and modify the contents of a hidden field. Do not use hidden fields for sensitive information or values whose integrity must be trusted.
Example
>>>printWidget "en" $ formify (Just $ Hidden 3) $ basic ""<div class="flex-form-div form-group"> ... <label for="flexident1"> </label> <input type="hidden" id="flexident1" ... value="3"> ... </div>
Instances
| (Formify a, PathPiece a) => BaseField (Hidden a) Source # | |||||
| Formify (Hidden a) Source # | |||||
Defined in FlexTask.Form.Formify Associated Types
Methods formDefaults :: Maybe (Hidden a) -> TypeList (FormTypes (Hidden a)) | |||||
| Show a => Show (Hidden a) Source # | |||||
| Eq a => Eq (Hidden a) Source # | |||||
| PathPiece a => PathPiece (Hidden a) Source # | |||||
Defined in FlexTask.InputTypes | |||||
| type FormTypes (Hidden a) Source # | |||||
Defined in FlexTask.Form.Formify | |||||
newtype SingleInputList a Source #
Wrapper type for lists. Use for a single field list input. Normally, lists are interpreted as multiple fields instead.
Example
>>>printWidget "en" $ formify @(SingleInputList String) Nothing $ basic "Input comma separated sentences"<div class="flex-form-div form-group"> ... <label for="flexident1"> Input comma separated sentences </label> <input id="flexident1" ... type="text" ...> ... </div>
Note that this does not actually enforce any kind of input syntax.
The generated input itself is a simple text field.
The comma separation is checked only when parsing with the matching formParser.
Constructors
| SingleInputList | |
Fields
| |
Instances
| Show a => BaseField (SingleInputList a) Source # | |||||
Defined in FlexTask.Form.Core | |||||
| Formify (SingleInputList a) Source # | |||||
Defined in FlexTask.Form.Formify Associated Types
Methods formDefaults :: Maybe (SingleInputList a) -> TypeList (FormTypes (SingleInputList a)) | |||||
| Parse (SingleInputList Text) Source # | |||||
Defined in FlexTask.Parser.Internal Methods | |||||
| Parse (SingleInputList Textarea) Source # | |||||
Defined in FlexTask.Parser.Internal Methods | |||||
| Parse (SingleInputList Integer) Source # | |||||
Defined in FlexTask.Parser.Internal Methods | |||||
| Parse (SingleInputList String) Source # | |||||
Defined in FlexTask.Parser.Internal Methods | |||||
| Parse (SingleInputList Bool) Source # | |||||
Defined in FlexTask.Parser.Internal Methods | |||||
| Parse (SingleInputList Double) Source # | |||||
Defined in FlexTask.Parser.Internal Methods | |||||
| Parse (SingleInputList Int) Source # | |||||
Defined in FlexTask.Parser.Internal Methods | |||||
| Show a => Show (SingleInputList a) Source # | |||||
Defined in FlexTask.InputTypes Methods showsPrec :: Int -> SingleInputList a -> ShowS # show :: SingleInputList a -> String # showList :: [SingleInputList a] -> ShowS # | |||||
| Eq a => Eq (SingleInputList a) Source # | |||||
Defined in FlexTask.InputTypes Methods (==) :: SingleInputList a -> SingleInputList a -> Bool # (/=) :: SingleInputList a -> SingleInputList a -> Bool # | |||||
| type FormTypes (SingleInputList a) Source # | |||||
Defined in FlexTask.Form.Formify | |||||
data SingleChoiceSelection Source #
Generic single choice answer type. Use if both of the following are true:
- You want an input that presents multiple answer choices, but only allows a single selection.
- There's no specific data type associated with this selection.
Instances
| Formify SingleChoiceSelection Source # | |||||
Defined in FlexTask.Form.Formify Associated Types
Methods formDefaults :: Maybe SingleChoiceSelection -> TypeList (FormTypes SingleChoiceSelection) | |||||
| Parse MultipleChoiceSelection Source # | |||||
Defined in FlexTask.Parser.Internal Methods | |||||
| Parse SingleChoiceSelection Source # | |||||
Defined in FlexTask.Parser.Internal Methods | |||||
| Generic SingleChoiceSelection Source # | |||||
Defined in FlexTask.InputTypes Associated Types
Methods from :: SingleChoiceSelection -> Rep SingleChoiceSelection x # to :: Rep SingleChoiceSelection x -> SingleChoiceSelection # | |||||
| Show SingleChoiceSelection Source # | |||||
Defined in FlexTask.InputTypes Methods showsPrec :: Int -> SingleChoiceSelection -> ShowS # show :: SingleChoiceSelection -> String # showList :: [SingleChoiceSelection] -> ShowS # | |||||
| Eq SingleChoiceSelection Source # | |||||
Defined in FlexTask.InputTypes Methods (==) :: SingleChoiceSelection -> SingleChoiceSelection -> Bool # (/=) :: SingleChoiceSelection -> SingleChoiceSelection -> Bool # | |||||
| type FormTypes SingleChoiceSelection Source # | |||||
Defined in FlexTask.Form.Formify | |||||
| type Rep SingleChoiceSelection Source # | |||||
Defined in FlexTask.InputTypes type Rep SingleChoiceSelection = D1 ('MetaData "SingleChoiceSelection" "FlexTask.InputTypes" "flex-tasks-0.1-1PNyq9qaMlVqATQpg44xv" 'True) (C1 ('MetaCons "SingleChoiceSelection" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAnswer") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int))) | |||||
singleChoiceAnswer :: Int -> SingleChoiceSelection Source #
Value with given number option selected.
singleChoiceEmpty :: SingleChoiceSelection Source #
Deprecated: This function only existed to satisfy a legacy interface in Autotool. It will be removed in a future version.
Value with no option selected.
getAnswer :: SingleChoiceSelection -> Int Source #
Retrieve the selected option. (The first selectable option is 1)
type MultipleChoiceSelection = MultipleChoice SingleChoiceSelection Source #
Same as SingleChoiceSelection, but for multiple choice input.
Use if both of the following are true:
- You want an input that presents multiple answer choices and allows selecting any number of them.
- There's no specific data type associated with this selection.
multipleChoiceAnswer :: [Int] -> MultipleChoiceSelection Source #
Value with given list of options selected. Sorts the input list and removes duplicates.
multipleChoiceEmpty :: MultipleChoiceSelection Source #
Value with no options selected.
getAnswers :: MultipleChoiceSelection -> [Int] Source #
Retrieve the list of selected options.
The first selectable option is 1.
[] if none are selected.
getAnswersAsIndices :: MultipleChoiceSelection -> [Int] Source #
Same as getAnswers but the selections are counted from 0 instead of from 1.
Use if you want to pass the selected answers to an indexing function like !! or !?.