This module contains a reusable FormList
type.
It is useful to build a variable list of forms based on a List
of values
.
{ forms : List (Form values field)
, add : () -> values
, attributes : Attributes
}
Represents a list of forms.
Note: You should not need to care about this unless you are creating your own custom fields or writing custom view code.
It contains a list of forms, a lazy add
action to add a new item to the list,
and some Attributes.
{ fields : List (Form.Base.FilledField field)
, delete : () -> values
}
Represents an element in a list of forms.
It contains the fields of the form and a lazy delete
action to remove itself
from the list.
{ label : String
, add : Maybe String
, delete : Maybe String
}
The attributes of a FormList
.
add
and delete
are optional labels for the add and delete buttons,
respectively. Providing Nothing
hides the button.
{ value : values -> List elementValues
, update : List elementValues -> values -> values
, default : elementValues
, attributes : Attributes
}
The configuration of a FormList
.
value
describes how to obtain a List
with the values of the forms
in the list.update
describes how to replace a new List
of element values in the
values
of the form.default
defines the values that a new element will have when added to the list.{ index : Basics.Int
, update : elementValues -> values -> values
, values : values
, elementValues : elementValues
}
Describes the state of a particular element in a form list.
index
is the position of the element in the list.update
defines how to update the current element.values
contains the current values of the form.elementValues
contains the current values of the element in the list.form : (FormList values field -> field) -> Config values elementValues -> (ElementState values elementValues -> Form.Base.FilledForm output field) -> Form.Base.Form values (List output) field
Builds a Form
with a variable list of forms.
Note: You should not need to care about this unless you are creating your own custom fields.