This module contains a value type for your form fields.
A blank value.
Use this to initialize the values of your empty fields:
values : SignupValues
values =
{ email = Value.blank
, password = Value.blank
, rememberMe = Value.blank
}Build an already filled value.
Use this when you are using forms to edit existing values:
values : Profile -> ProfileValues
values profile =
{ firstName = Value.filled profile.firstName
, lastName = Value.filled profile.lastName
}Obtain the data inside a Value.
If the value is blank, it returns Nothing, else it returns Just the value.
Note: You should only be using this in meta forms or
custom view code.
Transform a value.
For instance, this can be useful if you want to use a
Form.numberField with a Value Int instead
of Value Float:
numberOfApples : Form { r | number : Value Int } Int
numberOfApples =
Form.numberField
{ parser = round >> Ok
, value = .number >> Value.map toFloat
, update =
\value values ->
{ values | number = Value.map round value }
, attributes =
{ label = "How many apples do you have?"
, placeholder = "Type a number"
, step = 1
, min = Just 0
, max = Nothing
}
}
Represents a form field value.