Skip to content

Form example compatibility w/ 1Password extension #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions book/architecture/forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ view model =

viewInput : String -> String -> String -> (String -> msg) -> Html msg
viewInput t p v toMsg =
input [ type_ t, placeholder p, value v, onInput toMsg ] []
span [] [ input [ type_ t, placeholder p, value v, onInput toMsg ] [] ]


viewValidation : Model -> Html msg
Expand Down Expand Up @@ -144,10 +144,11 @@ We start by creating a `<div>` with four child nodes. But instead of using funct
```elm
viewInput : String -> String -> String -> (String -> msg) -> Html msg
viewInput t p v toMsg =
input [ type_ t, placeholder p, value v, onInput toMsg ] []
span [] [ input [ type_ t, placeholder p, value v, onInput toMsg ] [] ]
```

So `viewInput "text" "Name" model.name Name` can create a node like `<input type="text" placeholder="Name" value="Bill">`. That node will also send messages like `Name "Billy"` to `update` on user input.
So `viewInput "text" "Name" model.name Name` can create a node like `<span><input type="text" placeholder="Name" value="Bill"></span>`. That node will also send messages like `Name "Billy"` to `update` on user input.
(We wrap it in a span for compatibility with popular browser extensions, such as password managers.)

The fourth entry is more interesting. It is a call to `viewValidation`:

Expand Down