This is a tiny wrapper around Uniform.field and Uniform.viewField that makes all fields editable by default,
and does not require you to provide valueState in your values.
Describe how to get, set, parse the field's value.
parser specifies how to validate the value.
It needs a function that processes the value of the field and produces a Result of either:String describing an error,output.value specifies how to get the value from values. Most of the time it will be in a form of .fieldName.update specified how to update values with a new value.
Unfortunately, elm does not provide a special syntax for functions-setters like for getters, that's why
most of the time it will look like \values value -> { values | fieldName = value }Define a "classic" text field. Not mandatory to use, but can help to shorten your fields definition a bit.
All it does is calling field String.isEmpty.
It is intentional that there are no other similar helpers in the library. I encourage you to implement similar helper functions for your custom value types.
A type-safe way to view a single field from the filled form's fields.
viewNameField =
Uniform.viewField viewName
viewAgeField =
Uniform.viewField viewAge
viewForm model =
let
filled =
Uniform.fill userForm model.formValues
in
Html.div
[]
[ viewNameField
, viewAgeField
]Describe how to view a form's field.
It is a function that accepts the value to display and the update function that should be called in onInput handler like this:
viewName { value, update } =
Html.input
[ Html.Events.onInput (FormUpdated << update) ]
, Html.Attributes.value value
]
[]
Define a "classic", always-editable form field.
First argument is a function telling if the given value is empty. Useful for custom field types, but if you find yourself working mostly with text fields, take a look at
textField.