Skip to content

Commit

Permalink
doc: Add example of how to have a certain select option preselected
Browse files Browse the repository at this point in the history
  • Loading branch information
unhammer committed Nov 11, 2020
1 parent cea82e2 commit 3e9eee2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Guide/form.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,17 @@ Given the above example, the rendered form will look like this:
</form>
```

If you want a certain value to be preselected, set the value in the controller. For example, to have the first user be preselected in the above example:

```haskell
action NewProjectAction = do
users <- query @User |> fetch
let userId = headMay users |> maybe def (get #id)
let target = newRecord @Project |> set #userId userId
render NewView { .. }
```


### Select Inputs with Custom Enums

You can use select fields with custom defined enums too.
Expand Down

0 comments on commit 3e9eee2

Please sign in to comment.