ozmat/elm-forms/1.1.0

NOTE: this package is not compatible with Elm 0.19.1

Forms.Update

This module provides helpers for your update function. Please refer to the examples for a better understanding

Message

type Msg comparable
= UpdateStringField comparable String
| UpdateBoolField comparable Bool

Predifined messages to help updating a Field. UpdateStringField is for String Value Field and UpdateBoolField is for Bool Value Field

Update

updateForm : Msg comparable -> Form comparable err a -> Form comparable err a

This function will update a Form for you. Here is how to use it :

type YourMsg
    = Form (Form.Update.Msg comparable)
    | ....


yourUpdate : YourMsg -> Model -> Model
yourUpdate msg model =
    case msg of
        Form formMsg ->
            { model | yourForm = Form.Update.updateForm formMsg model.yourForm }


yourView : Model -> Html YourMsg
yourView model =
    ...
        onEvent (Form << Form.Update.UpdateStringField fieldKey)
        onEvent (Form << Form.Update.UpdateBoolField fieldKey)
    ...

Side effects

a
-> Msg comparable
-> (a -> comparable -> String -> Cmd msg)
-> (a -> comparable -> Bool -> Cmd msg)
-> Cmd msg

Helps defining some extra effects on a Field event. You can use this function to add your effects when a specific event is triggered on a Field.

effects model formMsg stringEffects boolEffects -- Cmd YourMsg
effectsS : a -> Msg comparable -> (a -> comparable -> String -> Cmd msg) -> Cmd msg

This version only defines effects for the UpdateStringField message

effectsB : a -> Msg comparable -> (a -> comparable -> Bool -> Cmd msg) -> Cmd msg

This version only defines effects for the UpdateBoolField message