NOTE: this package is not compatible with Elm 0.19.1
This module contains a type that represents a generic form field.
Note: You should not need to care about this unless you are creating your own custom fields or writing custom view code.
Represents a form field.
It contains:
value
update
attributes
These record fields are normally used in view code to set up the value and onInput attributes. For example, you could render a TextField like this:
onInput
TextField
view : (values -> msg) -> Form values output -> values -> Html output view onChange form values = let { fields, result } = Form.fill form values fieldsHtml = List.map (viewField onChange) fields -- ... in Html.form [-- ... ] [ Html.div [] fieldsHtml , submitButton ] viewField : (values -> msg) -> ( Form.Field values, Maybe Error ) -> Html msg viewField onChange ( field, maybeError ) = case field of Form.Text TextField.Raw { value, update, attributes } -> Html.input [ Attributes.type_ "text" , Attributes.value (value |> Value.raw |> Maybe.withDefault "" ) , Attributes.onInput (update >> onChange) , Attributes.placeholder attributes.placeholder ] [] _ -> -- ...
Represents a form field.
It contains:
valueof the fieldupdatefunction that takes a new field value and returns updated form valuesattributesof the fieldThese record fields are normally used in view code to set up the
valueandonInputattributes. For example, you could render aTextFieldlike this: