Hi,
I am new to Elm and am trying to add a button that toggles the visibility of the password fields (either as the standard password type or as text) but while I can do that hard-coding the boolean, I am getting an error when I add the update functionality.
Here are the parts of the code:
type alias Model =
{ form : Form
, view : View
}
type alias Form =
{ ...
, showPassword: Bool
}
type Msg
= ...
| TogglePasswordVisibility
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
...
TogglePasswordVisibility ->
let
updatePasswordVisibility = { model.form | showPassword = not model.form.showPassword}
in
({ model | form = updatePasswordVisibility}, Cmd.none )
div
[ class "text-sm mx-auto my-4 px-4 py-1 bg-slate-100 hover:bg-slate-200 duration-300 text-slate-900 w-36 rounded-full cursor-pointer "]
[ button
[ class "mr-2"
]
[ ]
, text (if form.showPassword then "Hide password" else "Show password")
]
Happy for any help in trying to solve this.