bgrosse-midokura / composable-form / Form.Base.FormList

This module contains a reusable FormList type.

It is useful to build a variable list of forms based on a List of values.

Definition


type alias FormList values field =
{ 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.


type alias Form values field =
{ 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.


type alias Attributes =
{ 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.

Helpers


type alias Config values elementValues =
{ value : values -> List elementValues
, update : List elementValues -> values -> values
, default : elementValues
, attributes : Attributes 
}

The configuration of a FormList.


type alias ElementState values elementValues =
{ index : Basics.Int
, update : elementValues -> values -> values
, values : values
, elementValues : elementValues 
}

Describes the state of a particular element in a form 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.