A Group is a group of Fields. The underlying data structure is a Dict
Is a shortcut to create a Field with the default String Value
string -- FieldValue (Forms.Value.defaultString)Is a shortcut to create a Field with the default Bool Value
bool -- FieldValue (Forms.Value.defaultBool)Is a shortcut to create a Field with a Group of fields. The function
takes a List of Tuple and creates the Group for you :
tupleExample : ( comparable, Field comparable )
tupleExample =
(comparable, string)
group [tupleExample, ...] -- FieldGroup (Dict.fromList [ ... ])Is a shortcut to create a Group of Fields. The function takes a
List of Tuple
someFormFields : Group comparable
someFormFields =
fields
[ ( comparable1, string )
, ( comparable2, bool )
, ( comparable3
, group
[ ( comparable4, string )
, ( comparable5, string )
, ( comparable6, string )
]
)
]Is a shortcut to create a Field with an initial String Value
stringWithValue "initial" -- FieldValue (String "initial")Is a shortcut to create a Field with an initial Bool Value
boolWithValue True -- FieldValue (Bool True)Retrieves the Value associated with a key. If the key is not found or
the Field is not a FieldValue returns Nothing
someFormFields : Group comparable
someFormFields =
fields
[ ( comparable1, string )
, ( comparable2, bool )
, ( comparable3, group [] )
]
getValue comparable1 someFormFields -- Just (String ...)
getValue comparable2 someFormFields -- Just (Bool ...)
getValue comparable3 someFormFields -- Nothing
getValue notfound someFormFields -- NothingRetrieves the Group associated with a key. If the key is not found or
the Field is not a FieldGroup returns Nothing
someFormFields : Group comparable
someFormFields =
fields
[ ( comparable1, string )
, ( comparable2, bool )
, ( comparable3, group [] )
]
getGroup comparable1 someFormFields -- Nothing
getGroup comparable2 someFormFields -- Nothing
getGroup comparable3 someFormFields -- Just (Dict.fromList [ ... ])
getGroup notfound someFormFields -- NothingUpdates the Value associated with a key. It will only update the Value
if the key is found, the Field is a FieldValue and the Values have the
same type
someFormFields : Group comparable
someFormFields =
fields
[ ( comparable1, string )
, ( comparable2, group [] )
]
setValue comparable1 (String ...) someFormFields -- updates
setValue comparable1 (Bool ...) someFormFields -- doesn't update
setValue comparable2 (...) someFormFields -- doesn't update
setValue notfound (...) someFormFields -- doesn't update
A
Fieldcan be a simple field with aValue(=FieldValue) or a group of fields (=FieldGroup)