hecrj/composable-form/7.0.1

NOTE: the latest version is 8.0.1

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 ( field, Maybe Error )
, 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.

  • 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.
type alias ElementState values elementValues =
{ index : 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.
(FormList values field -> field)
-> Config values elementValues
-> (ElementState values elementValues -> FilledForm output field)
-> 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.